cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
bubuta
Level: Powered On

Field validation on form submission & patchig

Hello,

 

I have PowerApps form connected to SharePoint list. The form uses various data sources (eg. Cascade drop downs takes info from another lists or excels, there is sharepoint standard drop downs, text fields etc). To save the information we are using Patch() and it works fine, but now we have to have field validation if some required remains empty.

 

There was idea to use:

OnSave: Set(Submitvar,"SubForm");SubmitForm(SharePointForm1); 

OnSuccess: Patch()

OnFailure: Notify( "Some mandatory fields are not filled in", Error )

Note - submitvar is used to call the Patch() through IF statement.

 

It works good in showing and highlighting fields with missing info, but it does not sava the information from cascade menues (ignoring Patch).

 

Is there a way to keep both validation and highlighting of fields in case of error, and save the form via patch (or update Submitted record with patch() data on success)?

 

3 REPLIES 3
Community Support Team
Community Support Team

Re: Field validation on form submission & patchig

Hi @bubuta ,

Could you please share a bit more about your scenario?

Do you want the Patch function (within OnSuccess property of Edit form) to be executed even though the SubmitForm function executes fail?

 

Based on the needs that you mentioned, I think you have some misunderstanding on the OnSuccess property of the Edit form. The OnSuccess property of the Edit form would be fired when the SubmitForm function executes successfully.

If the SubmitForm function executes fail, the OnSuccess property would not be fired, instad, the OnFailure property would be fired.

 

If you want the Patch function (within OnSuccess property of Edit form) to be executed even though the SubmitForm function executes fail, please take a try with the following workaround:

Set the OnSave property of SharePointIntegration control to following:

Set(Submitvar,"SubForm");
Concurrent(
SubmitForm(SharePointForm1),
Patch(...) /* <-- Type your Patch function here */
)

Please take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
bubuta
Level: Powered On

Re: Field validation on form submission & patchig

Hello @v-xida-msft ,

 

Sorry for being slowpoke with my answer 😄 I have tried your code, but it did not work for me.

What magic I did to implement the needed solution:

1. I took out all OnSuccess / OnFailure conditions;

2. I have switched Patch() to Collect() - not really sure if it was required, but i liked Collect() more;

3. I have set variables for the form:

OnVisible = Collect(Collection1, ContractTab); Set(notifwindEID, false);

4. I have created a group of Icons which looks similar to 'Notify' window with error text and Exit button

errornotify.png

 

 

5. I have set the visibility of the group as follows:

Visible = notifwindEID

6. For 'OnSave' action i have implemented an IF condition, which checks if the field is empty - 

If yes - Set(notifwindEID, true);

If not empty - run Collect() function and hide request.

 

The main minus here is the need to write multiple IF conditions to run validation for required fields. There might be more elegant way of doing this; but so far this is the only solution i could come up with. 

Community Support Team
Community Support Team

Re: Field validation on form submission & patchig

Hi @bubuta ,

Yeah, I also agree with the solution you provided. If you have solved your problem, please consider go ahead to click "Accept as Solution" to identify this thread has been solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (6,835)