Skip to main content

Notifications

Community site session details

Community site session details

Session Id : h7d0Oz6YeFhBcrW/TyOpQC
Power Apps - Building Power Apps
Unanswered

How to update Sharepoint list item when a form button is clicked

Like (0) ShareShare
ReportReport
Posted on 24 Mar 2020 04:56:44 by 21

Hi,

 

I'm new to powerapps and I'm designing a leave request form and a flow based on a Sharepoint list.

I desgined the form by clicking PowerApps->Customize forms

 

Below are the requirements

1. Save the form data to SP list when the user clicks the "Save" button and update the Sharepoint List Column "Status" to "Draft"

2. Save the form data to SP list when the user clicks the "Submit" button and update the Sharepoint List Column "Status" to "Submitted"

3. Update the Sharepoint List Column "Status" to "Cancelled" when the user clicks the "Cancel" button.

 

The user may save the form data first and later come and submit it for approval.

 

I tried the patch function for the Cancel button, but it gives an error

Patch.PNG

 

Could someone help me on how to achieve the above three requriements.

 

Form.PNG

Categories:
  • abcrandy Profile Picture
    42 on 06 May 2021 at 17:20:06
    Re: How to update Sharepoint list item when a form button is clicked

    @Rana1 Did you ever find a solution to this issue for newly created items?

  • Rana1 Profile Picture
    21 on 01 Apr 2020 at 07:17:26
    Re: How to update Sharepoint list item when a form button is clicked

    Hi @eka24 ,

     

    Your solution too worked for the "Cancelled " status and thanks for that. But I faced the same issue here also as the Status didn't update for newly created items when the form was submitted directly without saving. The Status updated correctly when a user opened a saved item and clicked Submit button. 

     

    I used the below formula for the Submit button .

     

    SubmitForm(SharePointForm1);Patch('Leave Request',First(Filter('Leave Request',Title=DataCardValue1.Text)),{Status:"Submitted"});RequestHide()

     

    I guess the issue is "Title " field doesn't returns a value as  record is created for the first time. But this works once a record it created , because a value is returned for the Title.

     

    Any idea how I can achieve this for newly created items. 

     

    regards,

    Rana1

  • Rana1 Profile Picture
    21 on 01 Apr 2020 at 06:57:08
    Re: How to update Sharepoint list item when a form button is clicked

    Hi @v-yutliu-msft ,

     

    Thanks for your reply.

     

    1. My "Status" field is a single line text field. 

    2. The choices for the field are Draft,Pending Approval,Approved,Rejected and Cancelled. 

     

    Your suggestion did work for Save and Cancel buttons.

     

    For the Submit button I have the  requirement  to update the Status as "Pending Approval" when the user clicks Submit button. This worked when the user first saves the form and comes back and submits it. But the Status didn't update when a user Submitted a new form directly without saving. Is there a way to update the Status when the user directly Submits the form?

     

    I used the below formula :

     

    SubmitForm(SharePointForm1);Patch('Leave Request',SharePointIntegration.Selected,{Title:"Click Here",Status:"Submitted"});RequestHide()

     

    Regards,

    Rana1

  • v-yutliu-msft Profile Picture
    on 24 Mar 2020 at 07:27:58
    Re: How to update Sharepoint list item when a form button is clicked

    Hi @Rana1 ,

    Could you tell me

    1)the "Status" field's data type?

    2)the choices of "Status" field, are they: "Draft", "Submitted" and "Cancelled"?
    I assume that this field is a choice field.

    If so, try this:

    1)set save button's OnSelect:

    SubmitForm(Formname);
    Patch(listname,SharePointIntegration.Selected,{Status:{Value:"Draft"}})
    //please replace with your formname, listname

    2)set submit button's OnSelect:

     

    SubmitForm(Formname);
    Patch(listname,SharePointIntegration.Selected,{Status:{Value:"Submitted"}})
    //please replace with your formname, listname

     

    3)set cancel button's OnSelect:

    Patch(listname,SharePointIntegration.Selected,{Status:{Value:"Cancelled"}})

     

    Please notice that

    1)you need to use {Value:...} to update a choice field.

    2)you need to use SharePointIntegration.Selected to represent the selected item of this list.

     

    Best regards,

  • eka24 Profile Picture
    20,921 on 24 Mar 2020 at 07:01:01
    Re: How to update Sharepoint list item when a form button is clicked

    Try:

    Patch('Leave Request', First( Filter('Leave Request', Title = TitleDataCardValue.Text ) ),

    { Status:"Cancelled"})

     

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,645 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,997 Most Valuable Professional

Leaderboard
Loading started