cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Post Prodigy
Post Prodigy

Update a choice field value inside an UpdateIf condition

Hello,

I have a button that should update two columns in an SP List, one of the columns is a single line of text and the other is a status column and its type is Choices that contains the following values (Open, Pending, Approved, Rejected).

I have tried to use the following formula:

If(
      VManager2,
      UpdateIf(
         'Purchase Order I',
         ID = SelectedReport.ID,
         {SecondMangSign : "Signed"},  ID = SelectedReport.ID, {Status:{Value: "Approve"}}
      ),
	  UpdateIf(
         'Purchase Order I',
         ID = SelectedReport.ID,
         {FirstMangSign : "Signed"},  ID = SelectedReport.ID, {Status:{Value: "Pending"}}
      )
   );

The first field was updated successfully, but unfortunately, the status column doesn't take effect to update the value based on what I have entered in the formula above.

Can please someone explains in detail and provide an example to achieve the above scenario inside the UpdateIf Condition?

Any help will be greatly appreciated.
Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Julien2 

Sorry for the delay in responding. Could you try this syntax to see if works better?

 

If(
      VManager2,
      UpdateIf(
         'Purchase Order I',
         ID = SelectedReport.ID,
         { SecondMangSign : "Signed", 
           Status:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
                  Value: "Approve"}
      ),
      UpdateIf(
         'Purchase Order I',
         ID = SelectedReport.ID,
         {FirstMangSign : "Signed", 
          Status:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
                  Value: "Approve"}
      )
   )

 

View solution in original post

4 REPLIES 4
Super User III
Super User III

Hi @Julien2 

I think that you're close. To patch a SharePoint choice column, you effectively need to patch a 'record' to your status field and the schema of this record requires us to specify a field called '@odata.type'.

The syntax you would use would look something like this:

If(
      VManager2,
      UpdateIf(
         'Purchase Order I',
         ID = SelectedReport.ID,
         {SecondMangSign : "Signed"},  ID = SelectedReport.ID, 
         {Status:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
                  Value: "Approve"}}
      ),
	  UpdateIf(
         'Purchase Order I',
         ID = SelectedReport.ID,
         {FirstMangSign : "Signed"},  ID = SelectedReport.ID, 
         {Status:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
                  Value: "Approve"}}
      )
   );

 

Here's another post with some example syntax:

https://powerusers.microsoft.com/t5/Building-Power-Apps/How-to-Save-Choice-field-value-using-UpdateI... 

Hello @timl ,

Thanks for providing an example.

I have tried to use exactly the same formula as you mentioned, but unfortunately, the status column doesn't update based on the value that I have provided, and again only the FirstMangSign and SecondMangSign fields text are updated.

Please have a look at the following screenshots:

Capture2.JPGResultsResults
Why do you think this problem occurs? Should I provide the DataCardValue53 instead of Value and use at the end of the function SubmitForm(Form1) or it's not the reason?

I have also tried to include the ID of the status value with no hope:

   If(
      VManager2,
      UpdateIf(
         'Purchase Order I',
         ID = SelectedReport.ID,
         {SecondMangSign : "Signed"},ID = SelectedReport.ID,         {Status:{
    '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
    Id: 3,
    Value: "Approved"
    }}
      ),
	  UpdateIf(
         'Purchase Order I',
         ID = SelectedReport.ID,
         {FirstMangSign : "Signed"},ID = SelectedReport.ID,
        {Status:{
    '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
    Id: 1,
    Value: "Pending"
    }}
      )
   );


Looking forward to your response.
Thank you!

Hi @Julien2 

Sorry for the delay in responding. Could you try this syntax to see if works better?

 

If(
      VManager2,
      UpdateIf(
         'Purchase Order I',
         ID = SelectedReport.ID,
         { SecondMangSign : "Signed", 
           Status:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
                  Value: "Approve"}
      ),
      UpdateIf(
         'Purchase Order I',
         ID = SelectedReport.ID,
         {FirstMangSign : "Signed", 
          Status:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
                  Value: "Approve"}
      )
   )

 

View solution in original post

Hello @timl ,

No need to be sorry for your delayed response. The syntax that you mentioned makes it works as expected.

Thank you for your support!

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (22,879)