cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
IntraAdmin
Helper II
Helper II

If(Form(HREdit).Valid, Submit(HREdit)) running OnSuccess even if Required field is blank

I have canvas app with a SharePoint list as a data source.  I have a field called Traveling that is required if the FormMode = New is true and EmpType = Contractor/StaffAug else it is only required if HREdit.Mode = New is false.  The following is the formula in Traveling.Required:

 

If(
    HREdit.Mode = New,
    If(
        EmpTypeDataCardValue18.Selected.Value = "Contractor/Staff Aug",
        true,false
    ),
    true
)

 

The formula in the Submit button OnSelect property is as follows:

If(HREdit.Valid,SubmitForm(HREdit))

 The OnSuccess property of the HREdit form is as follows:

Reset(txtSearch);Navigate(Gallery2,None);Set(varResetDir,true);Refresh(Onboarding)

 

When testing the app, the OnSuccess property of the HREdit form seems to run sending the user to the Gallery and displaying the required field error at the top of the gallery.  Why is the form submitting if the form is not valid?  The Traveling field is a dropdown choice field and not a combo box.

 

Thank you in advance.

10 REPLIES 10
TheRobRush
Super User
Super User

Just curious, is there a reason to let them press the submit button on an incomplete form at all? If not it might be easier to just set the display mode of the submit button to your check, then you will visually be able to see it lock/unlock. Even if you would like them to be able to press the button, and only submit based on the result of your formula, getting the result might be easier to visualize by doing it here first, and once it locks/unlocks as expected then moving it back to the onselect

_____________________________________________________________________________________
Like my answer? - Hit that Thumbs Up. Resolved the Issue? - Hit Accept as Solution.
This helps others find solutions to future issues!
RandyHayes
Super User
Super User

@IntraAdmin 

Your logic seems a little off:

...required if the FormMode = New is true and EmpType = Contractor/StaffAug else it is only required if HREdit.Mode = New is false

Are you stating that if the form is New and the EmpType is as specified that it is required, but that if it is JUST in new mode, then it is not required?

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@RandyHayes The FormMode =  New is true and EmpType = Contractor/StaffAug it is required, if the FormMode is not new, then it will always be required.  Does that make sense?

 

RandyHayes
Super User
Super User

@IntraAdmin 

Not entirely...check this logic table based on what you are saying:

FormMode EmpType Required
New Contractor/StaffAug True
New Something/Else False
Edit NA True

 

If I follow what you are saying this is what I come up with.

Please validate.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@TheRobRush @RandyHayes  No reason to let them push the button.  The issue with disabling the button is that the form is quite large and the user will not know what field is missed.  Not all fields are required by all users granted not all users can see all fields.  Fields are based upon AzureAD group membership.  I have variables that are set OnStart to check if the user is in an AzureAD group.  If so, set the variable to true.  In some cases, a user is part of two different groups.  The Traveling field is the only required field and is seen first by either HR or a hiring manager.  They are the only two who can edit it and BSD is the only group who can view it.  BSD and any other users will not even know the item exists to look at their part until either HR or the Hiring Manager has submitted.  The Hiring Manager only submits before HR if the EmpType = Contractor/StaffAug.  The Hiring Manager is the one who is required to fill in whether the employee will travel.  Otherwise, HR creates the new item, an email is sent to the Hiring Manager with a deep link to the item where the Hiring Manager then would be responsible for filling out the Traveling field.  After the following two scenarios, the other users then get an email that there is a new item.  Only the Hiring Manager can edit the traveling field.

RandyHayes
Super User
Super User

@IntraAdmin 

So was the logic table I sent you correct then?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@RandyHayes Sorry, I just saw the logic table.  Yes, it is correct.

RandyHayes
Super User
Super User

@IntraAdmin 

Then your Required property on the DataCard should be:

(Parent.Mode=FormMode.New && EmpTypeDataCardValue18.Selected.Value="Contractor/StaffAug") || !(Parent.Mode=FormMode.New)
_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
IntraAdmin
Helper II
Helper II

@RandyHayes I changed my formula in the Required property of the Traveler data card to the following but it seems to still be running the OnSuccess property's function of the HREdit form because it is navigating to the Gallery then showing the required field message at the top of the Gallery but not submitting to the SharePoint list.  I am testing this in the Power Apps Portal as this is a canvas app that has been live for about 5 months and do  not want to publish this while it is not working.  I can't see how that would be an issue.

If((Parent.Mode=FormMode.New && EmpTypeDataCardValue18.Selected.Value="Contractor/StaffAug") || !(Parent.Mode=FormMode.New),true,false)

 

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Users online (1,368)