Hi all,
I have a form with Data cards set as Required = True, and a submit button that is visable if the form is valid (all cards filled). If the form was successfully completed, and the submit button clicked, I had SubmitForm(Form); Navigate(ScreenSuccess)
This worked fine.
I wanted to add a "save draft" option, I followed Rezas video on how to do this here https://www.youtube.com/watch?v=y24AkK-OXy0.
My problem is that when the Submit button is clicked, the form always navigates to ScreenSuccess and the user doesn't see the required fields messages.
I can't work out from Reza's video how to do the navigation - e.g. navigate to ScreenSuccess if saved as draft, and stop navigation if the form is not complete (e.g. hide the submit button or whatever).
Seems like it should be pretty basic and I'm missing something. How can I do this?
Thanks for the responses, that is working.
One other question if you could help....
Previously I had the submit button displaymode set depending on all the Datacards being required and the form valid. But with Reza's example the the required property of each datacard is set depending on what button is clicked. Is there a way I can change the display mode of the submit button so its only in edit mode if the required fields are filled?
@Drrickryp is 100% correct! You should have nothing but SubmitForm as your function. Everything else should be handled in the OnSuccess or OnFailure actions of the form.
To add though, in your case, you can simply look at whatever column you are storing your draft status in and then navigate if needed.
Example formula in your OnSuccess action:
If(
!(Self.LastSubmit.Status.Value="Draft"),
Navigate(yourScreen)
)
This would navigate if the status is NOT Draft.
I hope this is helpful for you.
There should never be anything chained after SubmitForm() for the reasons you gave for the problem you are having. Any further commands should be put in the OnSuccess property of the form being submitted so that they are not executed unless the form is successfully submitted.