cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
opticshrew
Level: Powered On

Updating a record within SharePoint list using Patch function

Hey folks,

 

I'm trying to create and update a record within a SharePoint list using the Patch function.

 

It seems that I can both create and update the record however when updating the record the other fields are wiped. I need to do it in this fashion as the Form contains to fields that perform a lookup in SharePoint. In my experience you cannot have 2 lookup fields on a single form as this creates a "server-side" error.

 

Here is my "code" : 

 

Patch('HIEN Scheduling', Defaults('Scheduling'),
{
    Email : DataCardValue158.Selected,
    MigrationWave : DataCardValue154.Selected,
    Session : DataCardValue157.Selected,
    Location : DataCardValue156.Selected,
    UserApplications : DataCardValue5.Text,
    AppsInSCCM : DataCardValue6.Selected,
    Notes : DataCardValue1.Text
}
);

Patch('Scheduling', 
{Email : DataCardValue158.Selected}, 
{Asset: DataCardValue168.Selected})

Both "Email" and "Asset" are lookup fields within SharePoint. Essentially this uses Patch in the first case to create the record. The second patch filters the list to show the single "Email" (There is validation on the list so it will only ever bring back a single value) then updates the "Asset".

 

I've found that this erases the previous fields and only populates the field mentioned in the second patch. "Asset".

 

Thanks.

J

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Updating a record within SharePoint list using Patch function

If I am reading this correctly it is a syntax issue. Try 

Patch('Scheduling', 
Email = DataCardValue158.Selected, 
{Asset: DataCardValue168.Selected})

I don't have an example in front of me to test but I know if you are checking to see if Email equals DataCardValue158.Selected you would not use a : the colon is for assignment, not evaluation.  

Shane - Microsoft MVP, YouTube, and PowerApps Consulting for when you are in a bind to get this fixed quickly. And finally we now have PowerApps Training

View solution in original post

2 REPLIES 2
Super User
Super User

Re: Updating a record within SharePoint list using Patch function

If I am reading this correctly it is a syntax issue. Try 

Patch('Scheduling', 
Email = DataCardValue158.Selected, 
{Asset: DataCardValue168.Selected})

I don't have an example in front of me to test but I know if you are checking to see if Email equals DataCardValue158.Selected you would not use a : the colon is for assignment, not evaluation.  

Shane - Microsoft MVP, YouTube, and PowerApps Consulting for when you are in a bind to get this fixed quickly. And finally we now have PowerApps Training

View solution in original post

opticshrew
Level: Powered On

Re: Updating a record within SharePoint list using Patch function

Hi @Shanescows

 

You're right!

 

I also found a better way of doing it, strangely a form submission acts differently than a patch. Meaning I can submit to "lookup fields" at the same time without the issues with "SubmitForm".

 

Thanks,

J

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (4,597)