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?
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.
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.
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?