I’m building PowerApps app with 2 screen.
As data source, I’m suing SharePoint list named “Events”. In this SharePoint list, I have 10 columns.
At screen1, I’m using Form control and wants users to enter value for column 1 to 5. Other columns such as 6 to 10 should be unselected, hide from form control.
I put SAVE button on screen1 so that user should save all input by “SubmitForm” function.
SAVE button also navigate user to move Screen2 and I put InputBox for column 6 to 10 and want to use “Patch” all user inputs to the same line of SharePoint list items.
Submitting form on screen1 is OK, surely created SharePoint list item but at the next screen 2, I cannot successfully grab same list item. How should I write “Patch” to add items on a same list item?
Solved! Go to Solution.
Hi @Sam44,
Do you want to save your form data within the second screen into the same SP list item record the previous form submitted using Patch function?
I have made a test on my side, please take a try with the following workaround:
Set the OnSelect property of the "Save" button within the first screen to following formula:
SubmitForm(Form1);Navigate(Screen2,ScreenTransition.Fade)
Note: The Form1 represents the Form control within the first screen.
Set the OnSelect property of the "Patch" button within the second screen to following formula:
Patch( '20180907_case9', Form1.LastSubmit, { Status: { '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference", Id: 0, Value: DataCardValue10.Selected.Value }, Department: DataCardValue11.Text } )
On your side, you should type the following formula:
Patch(
Events,
Form1.LastSubmit,
{
Column6:DataCardValue6.Text,
Column7:DataCardValue7.Text,
...
Column10:DataCardValue10.Text
}
)
Note: The Form1 represents the Edit form within your first screen.
The GIF screenshot as below:
More details about the Patch function in PowerApps, please check the following article:
Best regards,
Kris
This might be helpful -
Patch( Events, Defaults( Events), Form1.Updates,Form2.Updates)
defaults function in the patch will create a new row/record and then updates from Form1 and Form2 will be patched
Vivek Bavishi aka That API Guy
PowerApps and Flow MVP
Blog | Twitter | YouTube | Community Profile | GitHub
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks for your help!
I'm using Patch but my question is once user submmited Form1 on screen1 then move to screen 2 which only has "Inputbox", how I can update same line of record items since only I can get is Form1.LastSubmit.ID?
If I write like : Patch(Events, Defaults(Events), Column6:InputboxA_on the Screen2), this create "new" SharePoint list item.
How I can "Add" values in Inputbox to exsisting list item record is my question need to be solved.
Hi @Sam44,
in reality, you want the "edit" the record that you just created by patching in the text of your inbox. The patch function is different for creating a new record vs. editing a record. On your first screen you are creating the new record so Defaults() is used for creating a new record in your data source. For editing that record, you need to identify it for the Patch command in the second screen.. One way is to have the Patch(Events, Last(Events), {Column6:InputboxA_.Text}). This will work if your Events table has 2000 records or less. I personally prefer to use First(Sort(... in case the data source grows to more than 2000 items.
In your case, it would be Patch(Events, First(Sort(Events,ID,Descending)), {Column6:InputboxA_.Text}) // You would have this command in the OnSelect property of the button on your 2nd screen.
Tip: Check out the Patch() function information at https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-patch
Hi @Sam44,
Do you want to save your form data within the second screen into the same SP list item record the previous form submitted using Patch function?
I have made a test on my side, please take a try with the following workaround:
Set the OnSelect property of the "Save" button within the first screen to following formula:
SubmitForm(Form1);Navigate(Screen2,ScreenTransition.Fade)
Note: The Form1 represents the Form control within the first screen.
Set the OnSelect property of the "Patch" button within the second screen to following formula:
Patch( '20180907_case9', Form1.LastSubmit, { Status: { '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference", Id: 0, Value: DataCardValue10.Selected.Value }, Department: DataCardValue11.Text } )
On your side, you should type the following formula:
Patch(
Events,
Form1.LastSubmit,
{
Column6:DataCardValue6.Text,
Column7:DataCardValue7.Text,
...
Column10:DataCardValue10.Text
}
)
Note: The Form1 represents the Edit form within your first screen.
The GIF screenshot as below:
More details about the Patch function in PowerApps, please check the following article:
Best regards,
Kris
Thanks @v-xida-msft !
Yes, I made it with your code!!
User | Count |
---|---|
140 | |
139 | |
77 | |
77 | |
71 |
User | Count |
---|---|
223 | |
179 | |
69 | |
67 | |
58 |