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

Approach for form validation dependent on status

Hi All,

I am looking for a solution to this problem:

A user needs fo fill in a form with a lot of fields (>20) all of them are required in the process which follows after submitting the form. I want to make it possible to submit the data in 'concept mode' which means that in this mode, none of the fields are required, so the user can fill in the form gradually and save data.

But I want to make sure that when the user submits the form when he/she thinks everything is filled in ('final' mode), the required fields are validated so all have a value. The data source is a SharePoint list.

 

I made the required property for all fields dependent of a status field which is manipulated using Patch. Sadly this approach does not work reliable. I use the on failure and on success events of the form in order to determine if required fields are filled in when in 'final' mode, the patched value for status is rolled back, i.e. it gets the previous value. It is difficult to explain I know...

 I think this behavior is perhaps related to SharePoint but I have not tested it with a more suited data source like SQL server.

 

But perhaps my approach to this problem is not right, so I would like to know if somebody has found a solution for this use case?

2 REPLIES 2
Super User
Super User

Re: Approach for form validation dependent on status

Here is one way to it. All the columns in the SharePoint list need to be not required. In the PowerApps Form all the DataCards related to the fields that you want conditionally required need to have the Required property changed to look at the StatusMode (Concept/Final).  I am assuming the status mode is a choice field on the SharePoint list.

 

Example: DataCard > Required: If(StatusModeDataCardValue.Selected.Value = "Final", true, false)

 

Then you should be able to use the SubmitForm() to save the changes to SharePoint. If the Status Mode is equal to Final then the Form will throw an error if all the required fields aren't filled out. If the status mode isn't equal to Final then it will allow you to save the data without the fields being required.



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.
BartSchaap
Level: Powered On

Re: Approach for form validation dependent on status

 

Hi  @Jeff_Thorpe 

Thank you for this answer, it is like the approach I choose. Some additional info to make my use case more clear:

 

I have 2 buttons in the edit screen: btnSaveAsConcept and btnSaveAsFinal.

When a user presses btnSaveAsConcept I use first Patch to update the status to 'Concept' and then submit form

When a user presses btnSaveAsFinal I use first Patch to update the status to 'Final' and then submit form

The required property for the fields is linked to this status as you describe. 

The OnSuccess event of the form : Back() this navigates to the gallery from which the edit screen is reached.

 

The problem is that when a user presses SaveAsFinal when one or more required field is not filled in and then decides to press SaveAsConcept, the form is submitted but in the gallery (and in SharePoint) the status is final and not concept as it should be in this case. The strange thing is that in the edit screen it is visible that the status is concept as you would expect. It seems that the status is reverted to final when navigating to the gallery. Any thoughts on this?

Best regards,

Bart

Helpful resources

Announcements
firstImage

PowerApps Monthly Community Call!

Join us next Wednesday for our Demo Extravaganza, October 16, 2019 8am PDT.

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

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 192 members 4,179 guests
Please welcome our newest community members: