cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Hermit
New Member

Saving updates from 4 PowerApps forms to 1 SharePoint entry

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.

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

6 REPLIES 6
WarrenBelz
Super User
Super User

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?

 

Hermit1_0-1646305650435.png

 

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?

 

Hermit1_0-1646307979840.png

 

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

Thanks @WarrenBelz! There's no way I would've worked that out myself

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (1,494)