Forum Discussion
Update Form Choice Field using Powerapps
I'm sure this is very simple but I've been struggling for hours. Please help if you can.
I am working on a SP list with custom powerapps form. One of my datacards is "status", and as I don't want users to select status directly, I want to programatically select the choice using a button, where its next value depends on its current value.
I don't want to use patch, as the list is visible and I need to see the choice value update in the list when I press the button, without refreshing, just like it does for the text-based datacards/fields, so I am using the below code, though I'm at a loss as I can't seem to programatically update ANYTHING, in real time.
UpdateContext({tempstatus:""});
Switch (ThisItem.Status.Value,
"Draft",
UpdateContext({tempstatus:"Submitted"}),
"Submitted",
UpdateContext({tempstatus:"In Work"}),
"In Work",
UpdateContext({tempstatus:"Draft"}),
"Approved",
UpdateContext({tempstatus:"PR Raised"}),
"PR Raised",
UpdateContext({tempstatus:"ECN Closed"}),
"ECN Closed",
UpdateContext({tempstatus:"Draft"}),
"Rejected",
UpdateContext({tempstatus:"Draft"})
);
UpdateContext({DataCardValue13:tempstatus}); // I have also tried UpdateContext({DataCardValue13:{value:tempstatus}});
SubmitForm(SharePointForm1)
//commented out patch
//Patch('Alt Component Register',First(Filter('Alt Component Register',ID = ThisItem.ID)),{Status:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",Id:2,Value:tempstatus}});
- GuyCarnegieCopper ContributorFor info, I got it working using this link.
https://powerusers.microsoft.com/t5/Building-Power-Apps/Pass-global-variable-value-to-select-drop-down-option-single/m-p/716430#M229261
The ".value" bit on the end of the formula was not required though.