cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Ras21
Regular Visitor

Patching Lookup column in SP

It seems like no matter what I try, I get the same errors.

I have a table with general info, and a department lookup column. I can't figure out how to patch this value. I either get errors about it expecting a different schema, or not having an Id of type number. What's the correct way of patching a Lookup column value from the OnSelect on a button? I've looked up many solutions and none work for me. I display the info in a gallery and I have a button that should patch the changes.

This is an example of what a lot of other posts say to do:

Patch(Training,
         Defaults(Training),
        {Lookup:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
                        Id:Gallery1.Selected.ID,
                        Value:Gallery1.Selected.Title}
              }
         )

 

This gives me the schema error, missing id of number type error, and invalid arguments for Patch error.

13 REPLIES 13

@RandyHayes 
I changed the formula to both of the ones in your latest reply with the correct ID's, and they both give me the same errors. The reasoned i typed Id instead of ID was because it didn't find any property with the name ID, only Id

Ras21
Regular Visitor

@RandyHayes 

I've found the culprit. I went into my SharePoint Personal list, and looked at the Id property. Yes, the problem was that it's, for some reason, named Id, and not ID. I had to rename it to something new, and then back to ID. The code you gave me now works perfectly fine .. Thank you for your time regardless, you steered me in the right direction in the end.

@Ras21 

Glad you got to the root of it.  However, I am a little concerned that you have an ID column in your SharePoint list...that you have created.  SharePoint already has an ID column that is unique to each record.  That is the one that you should be using for ID's in SharePoint.

So, glad it's working, but watch out for potential issues if this is a custom column.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

@RandyHayes 
The column is not one that I created, weirdly enough. It appears to be the original ID column ,just under a different name.

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

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (2,919)