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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Validate form fields w...
Power Apps
Suggested Answer

Validate form fields when using patch?

(0) ShareShare
ReportReport
Posted on by 17
Hi all!
 
Hoping somone can offer some advice here.
 
I have a Form that is split over 2 tabs on my Powerapp.    In order to submit the form, I use the Patch function.
I normally use the SubmitForm() function and it automatically validates the fields and you get the relevant errors in red text(see screenshot:)
 
 
My question is this: 
 
How do I validate the same way when using the PATCH function? 
 
Is it possible to run the same validation as the SubmitForm() before doing the patch?
 
Thanks in advance
 
 
 
Here's my code:
 
//Old method of submit form
//SubmitForm(FormShiftData);
 
Patch('MWOS_Data_LN', Defaults('MWOS_Data_LN'), FormShiftData.Updates,FormRejectData.Updates);
 
If(
     // check if there were any errors when the test score was submitted
     !IsEmpty(Errors('MWOS_Data_LN')),
     // if true, show any error message
     Notify(
         Concat(Errors('MWOS_Data_LN'), Column&": "&Message),
         NotificationType.Error
     ),
     // else, go to success screen
     ResetForm(FormShiftData);
     ResetForm(FormRejectData);
     Refresh(ExistingRecordsView);
     Navigate(ViewMainScreen,ScreenTransition.Fade);
 
 )
Categories:
I have the same question (0)
  • Suggested answer
    WarrenBelz Profile Picture
    153,165 Most Valuable Professional on at
    Hi @StuDev​​​​​​​
    Try Form.Valid
    If(
       FormShiftData.Valid && FormRejectData.Valid,
       Patch(
          'MWOS_Data_LN', 
          Defaults('MWOS_Data_LN'), 
          FormShiftData.Updates,
          FormRejectData.Updates
       ),
       Notify(
          "Errors . . . ",
    	  NotificationType.Error
       )
    )

    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    LinkedIn    Buy me a coffee
  • StuDev Profile Picture
    17 on at
    Thanks Warren.
     
     
    Do I need to incorporate the error handling for the patch function after the form validation?
     
     
    Pseudo code in BOLD red
     
     
    IF (FormShiftData.Valid && FormRejectData.Valid) {
    //true - form is valid, now do the patch and the error handling
     
    Patch('MWOS_Data_LN', Defaults('MWOS_Data_LN'), FormShiftData.Updates,FormRejectData.Updates);
     
    If(
         // check if there were any errors when the test score was submitted
         !IsEmpty(Errors('MWOS_Data_LN')),
         // if true, show any error message
         Notify(
             Concat(Errors('MWOS_Data_LN'), Column&": "&Message),
             NotificationType.Error
         ),
         // else, go to success screen
         ResetForm(FormShiftData);
         ResetForm(FormRejectData);
         Refresh(ExistingRecordsView);
         Navigate(ViewMainScreen,ScreenTransition.Fade);
     
     )
    ELSE
    //show the required fields - Will it do this automatically? or do I need to anything?
     
    }
  • WarrenBelz Profile Picture
    153,165 Most Valuable Professional on at
    Hi @StuDev,
    Unfortunately, you cannot have it both ways - if it passes the test, then there are no errors to display. You would need to go back to what you had before and capture any errors, This would also mean some manual action to capture missing fields.
  • WarrenBelz Profile Picture
    153,165 Most Valuable Professional on at
    A quick follow-up to see if you received the answer you were looking for or if you need further assistance.

    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    LinkedIn   

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 559 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 315 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 250

Last 30 days Overall leaderboard