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

Community site session details

Session Id :
Power Apps - Error Handling
Answered

Validity check prior to submission and error

(0) ShareShare
ReportReport
Posted on by 98
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?
I have the same question (0)
  • Suggested answer
    jrletner Profile Picture
    720 Super User 2025 Season 2 on at
    Validity check prior to submission and error

    Hmmmm....In some cases, adding a short delay between the refresh and the check can help mitigate data refresh latency issues. Use Concurrent to manage the sequence:

    Concurrent(
    Refresh('Workflow Cycle Labor Allocation'),
    Set(
    varLatestSelection,
    LookUp('Workflow Cycle Labor Allocation', ID = varSelection.ID)
    ),
    If(
    varLatestSelection.NumberTaken < varLatestSelection.NumberAvailable,

     
    // Slot available, proceed
    Patch(
    'Workflow Cycle Labor Allocation',
    varSelection,
    {NumberTaken: varSelection.NumberTaken + 1}
    );

     
    Patch(
    'Work Enrollment List',
    Defaults('Work Enrollment List'),
    {
    'Employee Name': User().FullName,
    Workflow: varSelection.'Workflow and Skill Lvl'
    }
    );
    Navigate(Submitted),

     
    // Slot unavailable, redirect to failure
    ResetForm(Form1);
    Navigate(Failure)
    )
    );
  • ShanePhillips Profile Picture
    98 on at
    Validity check prior to submission and error
    Thank you for the suggestion jrletner.  There are a couple of errors in the new code. Is there a way to delay the second use of the table?
     
     
     
     
  • Verified answer
    jrletner Profile Picture
    720 Super User 2025 Season 2 on at
    Validity check prior to submission and error

    Since Concurrent is causing issues due to dependencies and restrictions on navigation, let's avoid using it altogether. Instead, we'll separate the actions into steps:

    1. Refresh the Data Source First (to ensure data is up-to-date).
    2. Use LookUp to Check Availability.
    3. Proceed with the Conditional Logic.
    By refreshing the data source and using LookUp immediately after, we pull the most current version of the selected item directly from the data source. This ensures that our validation checks are based on real-time data.
     
    Depending on the amount of data that's being refreshed, it might still not have everything refreshed in time, so we could look into adding a timer control that's fired after the refresh command.  Using a timer to create a slight delay between the Refresh and LookUp operations, allowing Power Apps to better ensure that the refreshed data is fully up-to-date before the LookUp function runs. While this isn’t a true "pause," it can help address timing issues in cases where immediate consecutive actions may not always retrieve the latest data.
     
    But let's see if this will work for you first.


    // Step 1: Refresh the data source
    Refresh('Workflow Cycle Labor Allocation');

    // Step 2: Look up the latest version of the selected item to check availability
    Set(
    varLatestSelection,
    LookUp('Workflow Cycle Labor Allocation', ID = varSelection.ID)
    );

    // Step 3: Check if the slot is still available
    If(
    varLatestSelection.NumberTaken < varLatestSelection.NumberAvailable,

    // Slot is available, proceed with patching
    Patch(
    'Workflow Cycle Labor Allocation',
    varSelection,
    {NumberTaken: varSelection.NumberTaken + 1}
    );
    Patch(
    'Work Enrollment List',
    Defaults('Work Enrollment List'),
    {
    'Employee Name': User().FullName,
    Workflow: varSelection.'Workflow and Skill Lvl'
    }
    );

    // Navigate to Success Screen
    Navigate(Submitted),

    // Slot is unavailable, navigate to Failure Screen
    ResetForm(Form1);
    Navigate(Failure)
    )
  • ShanePhillips Profile Picture
    98 on at
    Validity check prior to submission and error
    YOU ARE AMAZING!!
     
    Thank you!  I've been banging my head a little too long on that.  I learned something very useful.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 663 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 398 Super User 2025 Season 2

#3
developerAJ Profile Picture

developerAJ 235

Last 30 days Overall leaderboard

Featured topics