Hello all,
I'm developing a task sign up app for our business, and I have two SharePoint lists it is linked to. One is the work allocation matrix which is essentially the list of what the task is and how many people are needed for it.
The form piece of this app writes data to another list with employee name and their designated selection.
When the app opens, you have data cached in the gallery and are able to make a selection, which is set as a variable named "varSelection". When two people select one item and they both have that item available in their gallery, they select said item and only one spot is available, the first person to submit gets their record written into the Work Enrollment List. The other person should be routed to the failure screen with the message to try again.
I've tried this a couple of different ways, and each has a data refresh and an "If" statement as part of the validity check. My problem is that the second person, who should be routed to "Full, please try again", still navigates to the success screen though they get an error banner at the top of the screen, shown below. It seems to me that Power Apps recognizes that the slot is taken but does not execute the user-friendly redirect.
Here is my OnSelect property:
//Refresh data cache
Refresh('Workflow Cycle Labor Allocation');
//Check to see if the selection is still available
If(
varSelection.NumberTaken < varSelection.NumberAvailable,
//Patch in the +1 to NumberTaken tally
Patch(
'Workflow Cycle Labor Allocation',
varSelection,
{NumberTaken: varSelection.NumberTaken + 1}
);
//Update Work Enrollment List
Patch(
'Work Enrollment List',
Defaults('Work Enrollment List'),
{
'Employee Name': User().FullName,
Workflow: varSelection.'Workflow and Skill Lvl'
}
);
//On Success
Navigate(Submitted)
,
//On Failure
ResetForm(Form1);
Navigate(Failure)
)
___________________________________________________________________________
And I have also tried this without patching the new record and using SubmitForm(Form1) tied to a submit button as shown below, with the OnSuccess and OnFailure properties following:
OnSelect =
Refresh('Workflow Cycle Labor Allocation'); //Refresh data cache
If(
varSelection.NumberTaken < varSelection.NumberAvailable,
SubmitForm(Form1), // If the slot is available, submit the form
Navigate(Failure) // If the slot is unavailable, navigate to the failure screen
);
OnSuccess =
Refresh('Workflow Cycle Labor Allocation');
If(
varSelection.NumberTaken < varSelection.NumberAvailable,
//Patch in the +1 to NumberTaken tally
Patch(
'Workflow Cycle Labor Allocation',
varSelection,
{NumberTaken: varSelection.NumberTaken + 1}
);
Navigate(Submitted),
Navigate(Failure)
)
OnFailure =
ResetForm(Form1);
Set(varSelection,Blank());
Navigate(Failure);
Both methods have the same result. Success screen at failure with the above error.
Any tips on how to properly execute a user message or redirect properly?