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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Field Validation Share...
Power Apps
Answered

Field Validation SharePoint Integration Power Apps-Best Practices

(0) ShareShare
ReportReport
Posted on by 42

What is the best practice for performing field validation and then adding a formula to the "OnSave" in SharePointIntegration that maybe checks a variable that will prevent the form submission (SubmitForm(SharePointForm1)?

 

For instance, I have a field, "ExistingEmailAddress" which has the following formula in its "ErrorMessage..." and "StarVisible..." control: If(And(!IsBlank(ExistingEmailAddress_Value.Text),!IsMatch(ExistingEmailAddress_Value.Text,Email)),true,false)

 

save.png

I want to prevent the Form from Saving if there are any failed field validations on the form. I understand that an If-statement should be added to the OnSave event in SharePointIntegration. I don't want to have to enter all of the field validations on the form in the OnSave event as well. Maybe checking a value of a hidden field on the form that gets updated by the other fields when they are updated and fail validation?

spintegration.png

Also, can a message be generated saying there are incorrect values in the form?

Thanks,

Jan

 

save.png
Categories:
I have the same question (0)
  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @janla2112 

    My suggestion would be that you build off of your formulas.

    For example, you have your email field, set the Visible property of the error message to the following:

    !IsBlank(ExistingEmailAddress_Value.Text) && !IsMatch(ExistingEmailAddress_Value.Text, Email)

    (no need for the redundant true/false in your original formula)

    Also, you mentioned that your star label was set to the same visible as the message - I would think that you want the "required" star to be visible all the time.

     

    If you have any other fields that need complex validation (beyond required), then do the same with their messages. 

     

    NOW, put a Toggle control on your screen.  Let's call it tglValidForm.  Set the Default property to:

       yourFormName.Valid && !yourEmailErrorLabel.Visible && !otherErrorLabels.Visible

    This will set the toggle true if the form is valid (all required fields are completed) and none of the error messages are showing.

     

    Now, in your OnSave, you can set the formula to the following:

        If(tglValidForm.Value, SubmitForm(SharePointForm1)

     

    Finally, you can set the toggle control visible property to false, as users don't need to see it.

     

    Also, I notice you have an isDirtyItem variable...if you are checking if the form has changed, you can simply utilize the Unsaved property of your form.  It will tell you if it is Dirty or not.

     

    I have a video on doing form validations and one on all of the properties and features of EditForms that might be worth reviewing as well for more hints.

     

    I hope this is helpful for you.

     

     

  • janla2112 Profile Picture
    42 on at

    Randy, thanks again for your assistance. That worked great. I will review the other links that your provided. Thanks for those as well!

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 305 Most Valuable Professional

#2
11manish Profile Picture

11manish 212

#3
Valantis Profile Picture

Valantis 167

Last 30 days Overall leaderboard