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
Highlighted
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.

1 REPLY 1
Highlighted
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.

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Tomorrow, September 18th at 8am PDT

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

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

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 297 members 5,045 guests
Please welcome our newest community members: