web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Apps
Unanswered

Save as Draft

(0) ShareShare
ReportReport
Posted on by 117

Hi,

 

I am building a form and saving the input in SharePoint. The form is for submitting information about a person when he is leaving the company so the various departments have the correct information to remove the person from all systems.

 

I have 2 screens. The first one is for showing an overview of submitted forms. The other screen is a ViewEdit screen. In the ViewEdit screen I have 2 buttons. One for saving as draft and one for submitting the form. Both navigate back to the overview screen. But only the Save as draft button should then show an edit icon in the Overview screen of that item. I do not want people to be able to edit once submitted. So then the Edit icon should not be shown.

 

I would like to use some kind of status label in the Overview screen per created form with statusses Draft and Final. And then make sure the button Save as draft writes back the status Draft and the button Submit writes back the status Final in the Overview screen. Then I can use the Visible field of the Edit icon to have a look at the status. But I am lost which codes in which fields to use in the buttons, and then also the code in the Visible field of the edit icon in the Overview screen.

 

Thanks and regards,

Ewoud

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @Ewoud 

    Do you have a Status column in your list?  You should.  And it should be something like "Submitted" or "Draft".  

    If you have that, then you can base all the visibility or icons off of that column value.

     

    I hope this is helpful for you.

  • Ewoud Profile Picture
    117 on at

    @RandyHayes 

    Yes I have a SharePoint Column for status which is a choice field.  For the buttons Save as Draft and Submit I have added the following code:

    Set(RequiredFields;false);; SubmitForm(frmNieuweAanvraag) & Navigate(ScnOverview;ScreenTransition.Cover) Set(RequiredFields;true);; SubmitForm(frmNieuweAanvraag) & Navigate(ScnOverview;ScreenTransition.Cover)

    But what code do I need to add to update the Status field?

    On the Overview screen where I want the Edit icon to be visible when the status is Draft I have added the following code to the Visible field:

    If(ThisItem.Status.Value = "Concept";true;false) //"Concept" is Dutch for "Draft". 

    Unfortunately it doesn't work. The ThisItem statement isn't recognized.

    I have added 2 images with Dutch words. Buttons on the first image are Annuleren -> Cancel, Concept opslaan -> Save as Draft, Indienen -> Submit.

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @Ewoud 

    So, there are some syntax issues with your formula, but let's outline it now...

     

    Saving as Draft or Submitting:

    For this, I would put a variable into action.  Let's call it lclStatus.  

    Now, for the Default property of your Status datacard in your EditForm, put the following formula:

    If(!IsBlank(lclStatus), 
     {Value: lclStatus; 
     '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference"
     };
     ThisItem.ChoiceColumn
    )

    In your Save as Draft (opslaan) button OnSelect action, put the following formula:

    UpdateContext({lclStatus:"Concept"});;
    SubmitForm(frmNieuweAanvraag);;
    UpdateContext({lclStatus:Blank()})

    In the OnSuccess action of your frmNieuweAanvraag edit form, put the following formula:

    Navigate(ScnOverview;ScreenTransition.Cover) 

    In your Submit (Indienen) button put the following formula (and actually, I am not sure what you are using for submitted status in your Choice column, but substitute the "Ingediend" below with that):

    UpdateContext({lclStatus:"Ingediend"});;
    SubmitForm(frmNieuweAanvraag);;
    UpdateContext({lclStatus:Blank()})

     

    The above should give you the ability to save as a submitted record or a draft record based on your Choice column.

     

    Now, for the visibility of the icon on your gallery.

    You can replace the Visible property of your Icon with this formula : ThisItem.Status.Value = "Concept"

    There is no need for the redundant If ... true; false.  The formula above will evaluate to true or false already. 

    However - the real question is why this would not work and give you an error.  I notice that you have the status aanvraag in a label.  That seems to work, so what is the formula on the Text property of that label?

     

    And also, just to be clear, your Status column is NOT defined in SharePoint as a "checkbox" choice column (multiple selections)?

  • Ewoud Profile Picture
    117 on at

    @RandyHayes

    I have added your formula to the Default Property of the Status Datacard (changed the comma in the first line into semicolon) but unfortunately I already received an error telling me that the If function has some invalid arguments.

    Adding your formulas in the Save as Draft (Concept opslaan) and Submit (Indienen) seem to work. I have also added the formulas 

    Set(RequiredFields;true);; SubmitForm(frmNieuweAanvraag) and Set(RequiredFields;true);; SubmitForm(frmNieuweAanvraag) because I want to have a check on the required fields. So the formulas look like this:

    Set(RequiredFields;false);; SubmitForm(frmNieuweAanvraag) &
    UpdateContext({lclStatus:"Concept"});;
    SubmitForm(frmNieuweAanvraag);;
    UpdateContext({lclStatus:Blank()})
    Set(RequiredFields;true);; SubmitForm(frmNieuweAanvraag) &
    UpdateContext({lclStatus:"Ingediend"});;
    SubmitForm(frmNieuweAanvraag);;
    UpdateContext({lclStatus:Blank()})

    Once the DataCard Status formula is working I can actually test it. "Ingediend" is the status for "Submitted" so that is fine for the formula.

    I have replaced the Visible property of the Icon with this formula : ThisItem.Status.Value = "Concept". I now receive the error Invalid argument type.

    Indeed I have the 'Status aanvraag' in a label. The Property Text has the formula:

    "Status aanvraag: " & ThisItem.Status.Value

     The Status column in SharePoint is not defined as a Checkbox. See attached image.

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @Ewoud 

    Apologies, had a coma and not a semicolon.  Please always check over the formulas provided as I hand-type them and have no syntax checking - plus the language encoding difference.

     

    The formula on the Status DataCard Default Property should be the following:

    If(!IsBlank(lclStatus); 
     {Value: lclStatus; 
     '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference"
     };
     ThisItem.ChoiceColumn
    )

     

    Your Save as Draft should be:

    Set(RequiredFields;false);; 
    UpdateContext({lclStatus:"Concept"});;
    SubmitForm(frmNieuweAanvraag);;
    UpdateContext({lclStatus:Blank()})

    I am not understanding why you would have two submits in your last formula??  You should be submitting once.  Is there something that Requiredfields produces?

     

    Your Submit should be similarly changed (also notice the status "Verstuurd" in this formula to match what you have in your choices for the column - you need to provide exact choices):

    Set(RequiredFields;true);; 
    UpdateContext({lclStatus:"Verstuurd"});;
    SubmitForm(frmNieuweAanvraag);;
    UpdateContext({lclStatus:Blank()})

     

    Can you provide me a screenshot of the Visible property where you are receiving the invalid argument error?

    Something is amiss there.

     

  • Ewoud Profile Picture
    117 on at

    @RandyHayes 

    No problem. I am glad you are willing to help me out here.

    The formula on the Status DataCard Default Property is giving me the error that the If function only has invalid arguments.

    status2.jpg

    The reason that I added 2 submits in my last formula is because my PowerApps knowledge isn't great yet. I 'stole' the first line from a different form.

    Herewith the screenshot of the Visible property.

    visible.jpg

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @Ewoud 

    A picture is worth a thousand words...

    I'll start with the easy one - the Icon Visible property...

    Your Icon is NOT inside of your Gallery.  It is simply on the screen outside of the Gallery.  I am pretty sure you wanted each record in your Gallery to have an Edit icon.  If so, you need to cut that icon off the screen and paste it into your Gallery template.

     

    Next, the Default property on the datacard.  My apology, it appears that I never mentioned to you to change the "ThisItem.ChoiceColumn" to be your actual column name.

    After learning more of your column names, your formula should be:

    If(!IsBlank(lclStatus); 
     {Value: lclStatus; 
     '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference"
     };
     ThisItem.Status
    )

     

    Let's see if that puts a nail in the lid!

  • Ewoud Profile Picture
    117 on at

    @RandyHayes

    Great, both formulas don't give an error anymore. Indeed I want every record to have an Edit icon. So after placing the Edit icon in the Gallery it worked.

    Unfortunately the buttons 'Concept opslaan' (Save as Draft) and 'Indienen' (Submit) don't do what is expected. When creating a new item and clicking either button, they both take me back to the overview screen which is good, but the label 'Status aanvraag' doesn't show 'Concept' or 'Verstuurd'. In the ViewEdit screen the status is also empty. So somehow it isn't writing the Status in the relevant fields.

    A complete picture of the formulas regarding Status:

    OnSelect property of Button 'Concept opslaan' (Save as draft):

    Set(RequiredFields;false);; 
    UpdateContext({lclStatus:"Concept"});;
    SubmitForm(frmNieuweAanvraag);;
    UpdateContext({lclStatus:Blank()})

    OnSelect property of Button 'Indienen' (Submit):

    Set(RequiredFields;true);;
    UpdateContext({lclStatus:"Verstuurd"});;
    SubmitForm(frmNieuweAanvraag);;
    UpdateContext({lclStatus:Blank()})

    Default property of Status datacardvalue:

    If(!IsBlank(lclStatus; 
    {Value: lclStatus; 
    '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference"
    };
    ThisItem.Status
    )

    OnSucces property of the frmNieuweAanvraag:

    Navigate(ScnOverview;ScreenTransition.Cover)

    Text property of label Status on the overview screen.

    "Status aanvraag: " & ThisItem.Status.Value
  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @Ewoud 

    Can you check the SharePoint list to see if any status is actually stored there when you submit?

  • Ewoud Profile Picture
    117 on at

    @RandyHayes 

    It isn't stored in SharePoint. When I do it the other way around, so changing the field in SharePoint, then it is changed in Powerapps

    If I change other fields in PowerApps then I see they are being stored in SharePoint.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard