cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
seadude
Level 10

Re: How to Trigger Field Validation Error Messages on Multi-Page Forms

oooooohhH!! Thats pretty slick @richcoresln !!
Does that work for partial form submissions?
Example:

  • 60 field form
  • Split into "Subforms" for usability
  • Can you check .Valid on a certain section (Form1), then, IF Valid, move to next section (Form2)
  • Repeat, but have each SubForm submit results (Patch, really) to the original record?

That sounds useful.

richcoresln
Level: Powered On

Re: How to Trigger Field Validation Error Messages on Multi-Page Forms

@seadudeyes that is kind of what is being achieved by using this:

 

If(!Form1.Valid, SubmitForm(Form1), Navigate(CustomFormScreen2));

This is on a "CustomFormScreen1" screens "Next" buttons "OnSelect" function.

This screen would not contain the entire data set available to Form1, with "CustomFormScreen2" containing a "Form2" with the remaining data set.

This could of course be repeated n number of times as necessary (achieving subforms).

 

We will only be calling Submit for the form when it is not valid; this results in the internal form validation being carried out (and failing as expected) and the forms error messages being displayed, but the submit function does not succeed. To answer your question, a form only seems to validate fields which have been added.

I agree this seems counter-intuitive which is why I would be interested if there was a cleaner way of achieving this (such as a form.Validate() function, however it does not appear so: https://powerusers.microsoft.com/t5/PowerApps-Ideas/Form-validation-without-Submission/idc-p/303558#...).

 

For completeness, the final form to "Submit" all the previous partial forms would be achieved via patch, this could look something like the following:

 

If(
    !Form2.Valid,
// Then
    SubmitForm(Form2),
// Else
    Patch(
        '[dbo].[MyTable]',
        Defaults('[dbo].[MyTable]'),
        Form1.Updates,
        Form2.Updates
    );
    If(
        !IsEmpty(Errors('[dbo].[MyTable]')),
    // Then
        Notify(
            "Failed to submit, check your internet connection and try again.",
            NotificationType.Error
        ),
    // Else
        ResetForm(Form1);
        ResetForm(Form2);
        Navigate(Home);
        Notify(
            "Subitted new record.",
            NotificationType.Success
        );        
    );    
);

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

Top Kudoed Authors
Users Online
Currently online: 64 members 3,317 guests
Recent signins:
Please welcome our newest community members: