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

SET() function is not setting the value.

HI Team,

The requirement is : When the field Form Status is "GMT On Hold" and user submits the form, the Form Status should change to "Resubmitted". When its "GMT Approved" it must change to "UserIDUpdated". In order to do so, I am using SET() in a switch statement and patching that value to a dropdown column in Sharepoint list. 

 

But each time its going to Default. And not setting the global variable value. The function is mentioed below.

 

Switch(FormStatus_1.Selected.Value,"GMT On Hold",Set(userformStatus,"Resubmitted"),"GMT Approved",Set(userformStatus,"UserIDUpdated"),"Completed",Set(userformStatus,"Visa Status Updated"),Set(userformStatus,"Defaut"));Patch('Visa Automation',{ID:Value( CurrentItemID)},{Form_x0020_Status:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
Id:Value(CurrentItemID),
Value:userformStatus}
});

 

FormStatus_1 = Dropdown field name

 

I also tried IF(), Even here, its not setting the value

 

If(FormStatus_1.Selected.Value="GMT On Hold",Set(userFormStatus,"Resubmitted"),If(FormStatus_1.Selected.Value="GMT Approved",Set(userFormStatus,"UserIDUpdated"),If(FormStatus_1.Selected.Value="Completed",Set(userFormStatus,"Visa Status Updated"),false)))

 

When I go to the variables in the powerapp, it doesnt show any value there either. 

 

Any kind of assiatnce will be appreciated. 

 

1 ACCEPTED SOLUTION

Accepted Solutions
egallis
Level 10

Re: SET() function is not setting the value.

Hi @schaubey,

What I can tell by looking at your formula is that your Patch function should more likely look like this:

Patch('Visa Automation',{ID:Value( CurrentItemID)},{Form_x0020_Status:LookUp(Choices(YourDataSource.Form_x0020_Status;Value=userformStatus))})

Can you try this and tell us if it changes anything ?

Emmanuel

View solution in original post

4 REPLIES 4
egallis
Level 10

Re: SET() function is not setting the value.

Hi @schaubey,

What I can tell by looking at your formula is that your Patch function should more likely look like this:

Patch('Visa Automation',{ID:Value( CurrentItemID)},{Form_x0020_Status:LookUp(Choices(YourDataSource.Form_x0020_Status;Value=userformStatus))})

Can you try this and tell us if it changes anything ?

Emmanuel

View solution in original post

Super User
Super User

Re: SET() function is not setting the value.

@schaubeyas @egallis is suggesting, the issue is most likely coming from your Patch statement not working.

Try the suggestion and perhaps also try this one:

Patch('Visa Automation',
   Lookup('Visa Automation', ID=CurrentItemID),
   {Form_x0020_Status:
     {'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
        Id:Value(CurrentItemID),
        Value:userformStatus
} }
)

In general, you don't want to be trying to assign the ID in your patch statement if you are working with an existing record.  Instead, you want to Lookup thta record from the source and "Patch" its values - in this case your Form_x0020_Status column.

 

Hope this adds some help.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
schaubey
Level: Powered On

Re: SET() function is not setting the value.

Your suggestion worked for me. 🙂

 

But I am just wondering, I still see value of global variable shown as no value in the variable section in powerapp.

Super User
Super User

Re: SET() function is not setting the value.

@schaubeyso, if I'm following along here, your formula should look like this now:

 

Switch(FormStatus_1.Selected.Value,
       "GMT On Hold",Set(userformStatus,"Resubmitted"),
       "GMT Approved",Set(userformStatus,"UserIDUpdated"),
       "Completed",Set(userformStatus,"Visa Status Updated"),
       Set(userformStatus,"Defaut"));

Patch('Visa Automation',
      Lookup('Visa Automation', ID=CurrentItemID),
      {Form_x0020_Status:
        {'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
          Id:Value(CurrentItemID),
          Value:userformStatus
        }
      } 
   )

 

 

And you're saying now that the userFormStatus variable is not getting set.  If that is the case, then you need to look at your FormStatus_1.Selected.Value and make sure it is what you are expecting - EXACTLY (including case).

 

I would throw a Label on the screen and set its Text property to FormStatus_1.Selected.Value.  Look at the label text and see if it really matches your Switch formula strings exactly.  

 

That is step one...make sure your variable is now getting set as expected.  This will then lead you to determining if you have the right values going to your SharePoint list during the patch.

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

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
Users Online
Currently online: 262 members 5,747 guests
Please welcome our newest community members: