web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Variables sometimes re...
Power Apps
Unanswered

Variables sometimes reset before patch?

(0) ShareShare
ReportReport
Posted on by 576

Hi all,

 

I am using two buttons within a gallery for Approve and Reject, which then brings up a dialog box (Microsoft Component) to ask for confirmation. Whether the user is in Approval or Reject mode is which of varSupClaimApprove or varSupClaimReject is true.

 

Approve button: 

 

 

UpdateContext({varSupClaimApprove:true,varSupClaimReject:false,varSelectedItem:ThisItem,varPopup:true})

 

 

Reject button:

 

 

UpdateContext({varSupClaimApprove:false,varSupClaimReject:true,varSelectedItem:ThisItem,varPopup:true})

 

 

 

When "Ok" is selected in the dialog box (visible with varPopup), this patches the approval status for that item. The code for the dialog box OnButtonSelect:

 

 

 

Switch(
 Self.SelectedButton.Label,
 "Cancel",
 UpdateContext(
 {
 varSupClaimApprove: false,
 varSupClaimReject: false,
 varPopup: false,
 varSelectedItem: Blank(),
 varBugFixer: true
 }
 );
 UpdateContext({varBugFixer: false});
 Reset(TextInput4_1),
 "Ok",
 Patch(
 'App-HDA-Supplementary-Claims',
 varSelectedItem,
 {
 Status: If(
 varSupClaimApprove,
 "Approved",
 varSupClaimReject,
 "Rejected",
 "Error"
 ),
 'Approver Comments': TextInput4.Text
 }
 );
 
//update the notifications table
RemoveIf(
 'App-HDA-Notifications',
 'Notification Type' = "Supplementary Claim" && LinkedID = varSelectedItem.ID && DriverID = varSelectedItem.DriverID
 );
 Patch(
 'App-HDA-Notifications',
 Defaults('App-HDA-Notifications'),
 {
 DriverID: varSelectedItem.DriverID,
 LinkedID: varSelectedItem.ID,
 'Notification Type': "Supplementary Claim",
 Details: "Request SPL-" & Text(
 varSelectedItem.ID,
 "000000"
 ) & " " & If(
 varSupClaimApprove,
 "Approved",
 varSupClaimReject,
 "Rejected"
 )
 }
 );
 UpdateContext(
 {
 varSupClaimApprove: false,
 varSupClaimReject: false,
 varPopup: false,
 varSelectedItem: Blank(),
 varBugFixer: true
 }
 );
 UpdateContext({varBugFixer: false});
 Reset(TextInput4)
)

 

 

 

This usually works, with status being patched depending on varSupClaimApprove/varSupClaimReject, except recently I've spotted the status appearing as "Error", which is the final 'else' part of the If statement within the Patch. Since either varSupClaimApprove or varSupClaimReject is set to true on the original button click, I do not understand how both can be false on the dialog "Ok" selection and "Error" patched instead?

 

My only thought is that the match results part of the Switch statement are being run concurrently and therefore both varSupClaimApprove/varSupClaimReject and being set to false before the patch has fully completed?

 

Any thoughts?

Categories:
I have the same question (0)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard