cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jaz_12
New Member

save as draft and edit form

Hi everyone, I am trying to build a form that allows users to save, edit the draft and also submit once the form has been completed. This is my first time trying to use powerapps, and would really appreciate if someone can please help me out. 

 

I created a home screen to show the progress (see below). However, whenever I go back to edit the 'save as draft' form, a new form starts and carries some information from the last form.  If I keep using the save function, more records will be created as drafts. Also when I click 'start a new form' it also shows some information from the previous form record.

 

  • The code for 'save' is " UpdateContext({locIsSubmit:false}); SubmitForm(Form1); "
  • The code for submit is " UpdateContext({locIsSubmit:true});SubmitForm(Form1)"
  • I have a status row in my form, the update code for it is "If(locIsSubmit,{Value:"Submitted"},{Value:"Draft"})"
  • The code I used for 'start new form' is ResetForm(Form1);NewForm(Form1);Navigate(form,None)'.

Is there a better way to do this type of form on powerapps? Looking forward to having your help. 

 

Screen Shot 2021-10-01 at 1.25.58 pm.png

2 REPLIES 2
StalinPonnusamy
Super User
Super User

Hi @jaz_12 

 

I believe the issue here is the order of execution. When you click on Save or Submit It sets the variable and submits the form. Data card (Status row update) may not be updated before submit form operation happens.

 

No guarantee of the order of operation. To solve this, we have 2 options

 

Option 1: Submit the form and Set the status OnSuccess property of Form

  • On Save OnSelect --> UpdateContext({locIsSubmit:false}); SubmitForm(Form1);
  • Set OnSuccess Property of Form to
    Patch(
        Datasource,
        LookUp(Datasource, ID = Form.LastSubmit.ID),
        { 
            Status : If(locIsSubmit,{Value:"Submitted"},{Value:"Draft"})
        }
    )

Option 2: Use Patch command for each button

 

For example, OnSelect of Save button to

    Patch(
        Datasource,
    If(
        EditForm1.Mode = FormMode.New,
        Defaults(Datasource),
        LookUp(
            Datasource,
            ID = Gallery.Selected.ID
        )
    ),
        { 
            Status : {Value:"Draft"},
//Other fields
        }
    )

 

The same goes for submit button

Status : {Value:"Submitted"},
StalinPonnusamy
Super User
Super User

Hi @jaz_12 

 

Please let us know if anything needs on your post. We can help with this.


Please do not forget to give kudos if you find the suggestion helpful or Accept it as a solution if works fine to help other users to find it useful.

 

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (1,808)