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

Announcements

News and Announcements icon
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?

Popup.JPG
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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 477

#2
WarrenBelz Profile Picture

WarrenBelz 341 Most Valuable Professional

#3
11manish Profile Picture

11manish 317

Last 30 days Overall leaderboard