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

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
R3dKap Memorable Member
Memorable Member

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
R3dKap Memorable Member
Memorable Member

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 @R3dKap 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
Frequent Visitor

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
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

Attending MBAS? Claim your badge

Attending MBAS? Claim your badge

Whether you’re streaming the digital event live, or watching on-demand, claim your attendee badge to sport on your profile.

‘Better Together’ T-Shirt Contest – Winner Announced!

‘Better Together’ T-Shirt Contest – Winner Announced!

And the winner is...

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Power Platform 2020 release wave 1 plan

Power Platform 2020 release wave 1 plan

Features releasing from April 2020 through September 2020

‘Better Together’ Integration Forum Launch

‘Better Together’ Integration Forum Launch

We're launching a how-to forum where you can learn about how Power BI integrates with other Power Platform products.

Emergency Response & Monitoring Solution

Emergency Response & Monitoring Solution

Microsoft has created a regional government emergency response and monitoring solution that is built on Power Apps and Power BI.

Top Solution Authors
Top Kudoed Authors
Users online (5,593)