cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
opticshrew
Helper I
Helper I

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
Shanescows
Super User
Super User

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

3 REPLIES 3
Shanescows
Super User
Super User

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

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

Happy to see u here Shane. Your powerapps videos are great !!!

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

PA Community Call

Power Apps Community Call

Next call is happening on April 21st at 8a PST.

MBAS Carousel

Sign up for our May 4th event!

May the fourth be with you, join us online!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors
Users online (39,821)