Hi,
We've created a new front end for a SharePoint List in PowerApps that has 4 forms connected via tab buttons. Each form has some of the SharePoint record fields (there are over 20 fields which is why we broke the form down to make it easier to enter data). We've created a save button using Patch that creates a new single record every time the entry is completed. That works fine. But how do we code a save to make an update to an existing entry?
Original Patch attempt that only creates new entries:
Patch('Savings Log',Defaults('Savings Log'),SharePointForm1.Updates,SharePointForm1_1.Updates,SharePointForm1_2.Updates, SharePointForm1_3.Updates,SharePointForm1_4.Updates)
I then tried a lookup to find the existing record but that still creates a new entry:
Patch('Savings Log',LookUp('Savings Log','Unique ID'=ThisRecord.'UniqueID'), SharePointForm1.Updates, SharePointForm1_1.Updates,SharePointForm1_2.Updates, SharePointForm1_3.Updates,SharePointForm1_4.Updates)
Any suggestions please? Many thanks for your help.
Solved! Go to Solution.
Hi @Hermit1 ,
It has to equal the ID of the item you are patching
Patch(
'Savings Log',
LookUp(
'Savings Log',
ID = SharePointIntegration.SelectedListItemID
),
SharePointForm1.Updates,
SharePointForm1_1.Updates,
SharePointForm1_2.Updates,
SharePointForm1_3.Updates,
SharePointForm1_4.Updates
)
You can also shorten it to this
Patch(
'Savings Log',
{ID: SharePointIntegration.SelectedListItemID},
SharePointForm1.Updates,
SharePointForm1_1.Updates,
SharePointForm1_2.Updates,
SharePointForm1_3.Updates,
SharePointForm1_4.Updates
)
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
Visit my blog Practical Power Apps
Hi @Hermit ,
I think this bit here is your issue
LookUp(
'Savings Log',
'Unique ID' = ThisRecord.'UniqueID'
)
Assuming you selected the record from a Gallery before you presented the forms
LookUp(
'Savings Log',
'Unique ID' = GalleryName.Selected.'UniqueID'
)
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
Visit my blog Practical Power Apps
@WarrenBelz Thanks for the reply. I'm not using a Gallery but instead the "Edit" option from the Sharepoint List. Is that the problem? It seems PowerApps doesn't know which record is being edited even though it loads the existing data correctly. Or I just don't know how to identify it in the code?
Hi @Hermit1 ,
You still need to identify the record you are editing - how do you do that ? Is this a SharePoint Integrated App? If so, it is
SharePointIntegration.SelectedListItemID
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
Visit my blog Practical Power Apps
Hi @WarrenBelz ,
Yes, that's right. It's a SharePoint integrated app - sorry should've mentioned that.
I'm trying this code but still get an error:
Patch('Savings Log',LookUp('Savings Log', SharePointIntegration.SelectedListItemID),SharePointForm1.Updates,SharePointForm1_1.Updates,SharePointForm1_2.Updates, SharePointForm1_3.Updates,SharePointForm1_4.Updates)
Do I still need the lookup?
Hi @Hermit1 ,
It has to equal the ID of the item you are patching
Patch(
'Savings Log',
LookUp(
'Savings Log',
ID = SharePointIntegration.SelectedListItemID
),
SharePointForm1.Updates,
SharePointForm1_1.Updates,
SharePointForm1_2.Updates,
SharePointForm1_3.Updates,
SharePointForm1_4.Updates
)
You can also shorten it to this
Patch(
'Savings Log',
{ID: SharePointIntegration.SelectedListItemID},
SharePointForm1.Updates,
SharePointForm1_1.Updates,
SharePointForm1_2.Updates,
SharePointForm1_3.Updates,
SharePointForm1_4.Updates
)
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
Visit my blog Practical Power Apps
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
User | Count |
---|---|
180 | |
52 | |
41 | |
38 | |
28 |
User | Count |
---|---|
255 | |
81 | |
71 | |
68 | |
66 |