Skip to content

Commit c51c084

Browse files
Update with better formula for set to a collection
1 parent 6f21e09 commit c51c084

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

powerapps-docs/maker/canvas-apps/sharepoint-form-integration.md

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,17 @@ The default generated form consists of the following controls and their correspo
3636

3737
* **Item** - The selected item from the list. This is set to First() item in the list for your convenience when working in Power Apps Studio.
3838

39-
**If(IsBlank(SharePointIntegration.Selected) || IsEmpty(SharePointIntegration.Selected),First('*YourListName*'),SharePointIntegration.Selected)**
40-
41-
* **OnSuccess** - Once the item is created or saved successfully, the form is reset and SharePoint hides the form.
42-
43-
**ResetForm(SharePointForm1); RequestHide()**
39+
```powerapps-dot
40+
If( IsBlank(SharePointIntegration.Selected) || IsEmpty(SharePointIntegration.Selected),
41+
First('*YourListName*'),
42+
SharePointIntegration.Selected )
43+
```
44+
[!TIP] This formula pattern ( ... SharePointDatasourceName.Selected ) works for the Item property of a form. See the customization section below for a formula pattern to set the value of a SharePoint record.
45+
* **OnSuccess** - Once the item is created or saved successfully, the form is reset and SharePoint hides the form.
46+
47+
```powerapps-dot
48+
ResetForm(SharePointForm1); RequestHide()
49+
```
4450
4551
* **SharePointIntegration** - The control responsible for communicating user actions between SharePoint and Power Apps.
4652
@@ -99,7 +105,6 @@ The **SharePointIntegration** control has the following properties:
99105
## Customize the default form
100106
Now that you have a better understanding of the default generated form and the **SharePointIntegration** control, you can change the formulas to further customize the forms. Here are some things to keep in mind when you customize forms:
101107
102-
* To create separate custom experiences for creating, showing, or editing an item, set the **OnNew**, **OnView**, or **OnEdit** formulas of the **SharePointIntegration** control to set variables or navigate to different screens.
103108
104109
* Use the **OnSave** formula of the **SharePointIntegration** control to customize what happens when a user clicks or taps **Save** in SharePoint. If you have multiple forms, make sure to submit the changes only for the form currently being used.
105110
@@ -112,6 +117,26 @@ Now that you have a better understanding of the default generated form and the *
112117
113118
* The properties for the **SharePointIntegration** control may not be available in **OnStart** or **OnVisible**, and those events execute only once while the list is loaded. You can use **OnNew**, **OnView**, or **OnEdit** formulas to run logic before the form is shown to the user every time.
114119
120+
## Commonly identified issues in working with the Sharepoint Integration Object
121+
The SharepointIntegration.Selected value, when set to a Collection on the OnView property, does not show the latest value. The recommended way to fix this is to use the SharepointIntegration.SelectedListItemID and then do a lookup on the table to get the selectedRecord.
122+
sample:
123+
124+
### OnView:
125+
126+
* Instead of :
127+
```powerapps-dot
128+
Set( selectedItem,
129+
SharePointIntegration.Selected );
130+
```
131+
* Use:
132+
```powerapps-dot
133+
Set( selectedLookupItem,
134+
LookUp( testSharepointIntegrationObject,
135+
ID=SharePointIntegration.SelectedListItemID ) );
136+
```
137+
138+
Collection Variables are not reset on closing the PowerApp form and the state is persisted for the entire session. Therefore if there are any use-cases where the variables need to be reset, clear the variables in the OnView property of the sharepointIntegration Object.
139+
115140
### See also
116141
117142
- EditForm, NewForm, SubmitForm, ResetForm, and ViewForm functions - [form functions in Power Apps](functions/function-form.md)

0 commit comments

Comments
 (0)