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

Update SharePoint choice column with null value

Hi

 

I'm trying to update a SharePoint choice field with null value. If the choice column already has value then I'm trying to reset with null value based on certain conditions in the form. I've tried using Blank() function and turned on experimental features but that doesn't seem to work for choice column but only for text inputs.

 

Say my form has 2 choice columns. Based on the value of the first choice column selection I want to update the value of the 2nd choice column in SharePoint. This is how my Patch function looks on click of submit button

 

Patch('My Form',{ID:ItemID},{Choice2_Column: {'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",Value:If(DataCardValue1.Selected.Value="No",Blank(),DataCardValue2.Selected.Value)}},Form1.Updates)

 

When creating a new form, suppose I select Yes for both the choice columns, I can see the value getting saved properly. However when I edit the item, if I select No in the first choice, the 2nd choice column is not set to blank after I save the data.

 

Thanks

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
CvdK
Level: Powered On

Re: Update SharePoint choice column with null value

I know that this is an old topic. But I could not find an answer anywhere, so after figuring it out for myself I decided to post the answer here for anyone else with this issue.

 

You can set the value of a choice field to empty or blank (if you configured the column to allow for empty of blank values in Sharepoint) by using the following code:

I'm using the function UpdateIf, but you can also use Update or Patch.

 

UpdateIf(Datasource, Condition, {FieldName: {'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
Id:-1,
Value:""}}
)

 

Datasource: Datasource to update

Condition: Condition to determine the record to update

FieldName: Name of the Choice Field to update

 

The key is to set the Id to -1

I've set Value to "" but you can also set it to Blank(), the effect is the same.

 

Hope this helps anyone.

View solution in original post

1 REPLY 1
CvdK
Level: Powered On

Re: Update SharePoint choice column with null value

I know that this is an old topic. But I could not find an answer anywhere, so after figuring it out for myself I decided to post the answer here for anyone else with this issue.

 

You can set the value of a choice field to empty or blank (if you configured the column to allow for empty of blank values in Sharepoint) by using the following code:

I'm using the function UpdateIf, but you can also use Update or Patch.

 

UpdateIf(Datasource, Condition, {FieldName: {'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
Id:-1,
Value:""}}
)

 

Datasource: Datasource to update

Condition: Condition to determine the record to update

FieldName: Name of the Choice Field to update

 

The key is to set the Id to -1

I've set Value to "" but you can also set it to Blank(), the effect is the same.

 

Hope this helps anyone.

View solution in original post

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 (5,311)