cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JackCuba
Frequent Visitor

Writing on a Choice field on SP list

Hello,

 

I have a list on SP with multiple columns. One of these columns is called "Region" and is a Choice column. From my app, I need to write into that column using a Patch() function. Problem is, Patch() does not like when I pass the Region column as the other ones. If I remove Region then Patch() is happy.

 

Here is my code.

Patch(MySharepointList, Defaults(MySharepointList), {FirstName: Label1.Text, LastName: Label2.Text, Region: Label3.Text})

 

Thanks!

2 ACCEPTED SOLUTIONS

Accepted Solutions
eka24
Super User
Super User

Try
Patch(MySharepointList, Defaults(MySharepointList), {FirstName: Label1.Text, LastName: Label2.Text, Region: {Value:Label3.Text}})

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

View solution in original post

JackCuba
Frequent Visitor

A coworker came through with this solution:

 

Patch(MySharepointList, Defaults(MySharepointList), {FirstName: Label1.Text, LastName: Label2.Text, Region:
{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference", Id: 123, Value: Label3.Text}

 

In other words, The Region column needs 3 things:

1- @odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference

2- ID: Record to be updated (You could use a Lookup here and retrieve the ID of the record just created).

3- Value to update

Thank you everyone for your help on this!

View solution in original post

4 REPLIES 4
eka24
Super User
Super User

Try
Patch(MySharepointList, Defaults(MySharepointList), {FirstName: Label1.Text, LastName: Label2.Text, Region: {Value:Label3.Text}})

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

View solution in original post

Eelman
Super User
Super User

@JackCuba 

Choice columns are Complex column types which are basically tables. So each item is a record and needs ALL the data to be Patched. This Shane Young video explains all you need (see around 6mins for your issue).

 

Using that vid and your code try

Region: {
   Value: Label3.Text,
   '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference
}

 

 

 

JackCuba
Frequent Visitor

A coworker came through with this solution:

 

Patch(MySharepointList, Defaults(MySharepointList), {FirstName: Label1.Text, LastName: Label2.Text, Region:
{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference", Id: 123, Value: Label3.Text}

 

In other words, The Region column needs 3 things:

1- @odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference

2- ID: Record to be updated (You could use a Lookup here and retrieve the ID of the record just created).

3- Value to update

Thank you everyone for your help on this!

View solution in original post

JackCuba
Frequent Visitor

I tried this after the solution I came across and it works. I'm accepting it as solution as well.

 

Thank you!

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (3,117)