Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Issues changing a "Choice" field fed from Sharepoint with a button press

Posted on by

Hi,

 

I have a Powerapps form which is feeding into a Sharepoint list - one of the fields is a Choice field on Sharepoint with "New", "Submitted", "Rejected" etc as options.  

 

I have the Default of this field setup as follows : 

 

 

If(
Request.Mode = FormMode.New,
{Value: "New"},
{Value: ThisItem.Status}
)

 

 

This sets the field to "New" if the form is opened in New Form mode.  I have a submit button which I am trying to make change this value to "Submitted" prior to submitting the form, then other buttons which will come later (Approve and Reject buttons) which will change this value to Rejected or Approved.  Not sure exactly how to do this though.  I've tried the following on the "Submit" button :

 

 

Set(Status, "Submitted")
+

SubmitForm(Request);

 

 

Now I understand why this isn't working - basically all I'm doing here is updating a Global variable called "Status" and not my Datacard called Status.  I'm just not sure on the correct code to update the Status Datacard.

 

Had a bit of a dig but can't find anyone with this exact issue.  Any help appreciated 🙂

  • Verified answer
    Re: Issues changing a "Choice" field fed from Sharepoint with a button press

    Hi @Powertron ,

     

    Is your requirement as shown below?
    1. If the form mode is New, the default value of the "Status" field is "New".
    2. Change the value of "Status" field to "Submitted" when submitting the form.
    3. Show Approve and Reject buttons.

     

    I have made a test for you  reference.

    1. Here is my SharePoint list.

    vyujincuimsft_0-1646818538775.png

    2. Select the Form and apply the following formula on its item property as:

    Last(datasource)

    3.  Select the Combo Box Control and apply the following formula on its DefaultSelectedItems property as:

    If(Form3.Mode=FormMode.New,{Value: "New"},{Value:ThisItem.status})

    4. Select the Add Icon and  apply the following formula on its OnSelect property as:

    NewForm(Form3)

     5. Select the Submit Icon and  apply the following formula on its OnSelect property as:

    SubmitForm(Form3);Patch(datasource,Last(datasource),{status:{Value:"Submitted"}});EditForm(Form3)

    6. Select the Approve Button and  apply the following formula on its OnSelect property as:

    Patch(datasource,Last(datasource),{status:{Value:"Approved"}});

    7. Select the Reject Button and  apply the following formula on its OnSelect property as:

    Patch(tmplist,Last(tmplist),{status:{Value:"Rejected"}});

    8. Select the Buttons and apply the following formula on its Visible property as:

    If(Form3.Mode=FormMode.New,false,true)

    Result:

    changestatus.gif

     

     

    Best Regards,

    Charlie Choi

  • Powertron Profile Picture
    Powertron on at
    Re: Issues changing a "Choice" field fed from Sharepoint with a button press

    I don't think this is going to do what I want.  Or certainly I think I'd prefer to find a way to do this without using variables.  Basically all I want the form to do is have "New" as the status when I enter it initially in New Form Mode and then change this when I hit the "Submit" button.  I have tried puzzling out the "Lookup" function but this doesn't seem to work like I'd have hoped.

  • David_G Profile Picture
    David_G 62 on at
    Re: Issues changing a "Choice" field fed from Sharepoint with a button press

    Yes you can set your Variable to "New" with the OnStart.

    If you prefer you can also use the OnVisible on the screen. But your variable will be set to "New" each time you navigate to this screen.

  • Powertron Profile Picture
    Powertron on at
    Re: Issues changing a "Choice" field fed from Sharepoint with a button press

    I'd need some way to set this value to "New" by default though.  Maybe I could move my code to OnStart or something for the App?

  • David_G Profile Picture
    David_G 62 on at
    Re: Issues changing a "Choice" field fed from Sharepoint with a button press

    Hi,

     

    Can you try to use your Status variable as default value of your Datacard ?

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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,591

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,090

Leaderboard