cancel
Showing results for 
Search instead for 
Did you mean: 

OnSubmit event for Form Controls for data validation

Hi,

Would be nice if we had an OnSubmit/OnSaving event on the form controls that we could use to do validations. Kind of like the PreSave function on sharepoint forms. If the event retured true powerapps would wubmit the form , otherwise it would not. We could put validation logic in the event and show/hide custom error messages as needed, 

 

As it is now, we need to scatter this logic throughout different controls. With various nested dependencies it can be difficult to understand where such logic should be declared. Providing a single place where such logic could be declared would make it much easier to develop and also much easier for a new person to understand what the form is doing.

 

I see the Validate method can be used to peroform some validations based on the schema, but there are other validations we often need-- which cannot be expressed in the schema-- that would be ideal candidates for a OnSubmit event.  Particularly when there are a lot of interdependancies between fiels on a form.

 

Status: New
Comments
Level 10

Hi @RussellGove 

 

I agree with your thoughts and have faced the same problem. We use the EditForm.Valid method to check if the form is valid before submitting. We then use the !Parent.Valid on the asterisk in the cards to show which fields still have to be completed before allowing the submit. 

 

Please see below video that discusses this in more detail.

https://youtu.be/7O8HCz37Q0A

 

Dawid van Heerden
Follow on Twitter: @davestechtips
Subscribe to YouTube: https://www.youtube.com/davestechtips?sub_confirmation=1
**If you found this reply helpful, please mark this as the answer to close the topic and make it easier to find for other people with similar questions.

Level 10

Great video Dawid. cant wait to try your ideas on my next app!

Level 10

Thank you very much @RussellGove, let me know how it goes. 😉