
Announcements
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?