cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
Super User
Super User

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
Highlighted
Super User
Super User

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

Highlighted

@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.
Check out my PowerApps Videos too!
Highlighted

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.

Highlighted

@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.
Check out my PowerApps Videos too!

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (10,970)