cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
blanghorst
Level: Powered On

Field update as part of submit rule

Let's say I have a PowerApp which is a custom SharePoint list form.  In the list, there is a field called "Status" which is a choice column with 3 values:  New, Submitted, Approved.  When a user creates a new form, status defaults to "New" and the status field is displayed in View mode so that it can't be changed.  When the user clicks the "Submit" button, I want the status field to update to Submitted status and then the form to be saved.  I'm not clear on the syntax for updating that Status column value in code prior to form submission.  I am sure it is easy but can anyone give me a hint?

6 REPLIES 6
pNabin
Level 8

Re: Field update as part of submit rule

Hi @blanghorst,

 

You need to create a new variable (like varStatus) and set the default value of Status field to varStatus whereas items os status  be New, Submitted, Approved. 

 

Then, OnSelect property of button submit, assign varStatus value to "Submitted" and save/submit the form like

OnSelect = UpdateContext({varStatus:"Submitted"}); SubmitForm(Form1)

Hope this will help you.

 

- Nabin

blanghorst
Level: Powered On

Re: Field update as part of submit rule

Thanks!  I'll give it a shot.

blanghorst
Level: Powered On

Re: Field update as part of submit rule

Hi Nabin,

 

So, I tried this and ran into a problem.  Correct me if I'm wrong, but I think you're saying the following:

 

1. Use a variable called varStatus to store the Status value.

2. Set the default value of the Status column to varStatus.

3. Place the rule in your post on a button.  When the button is clicked, it will update varStatus and therefore, the Status column.

 

If I try to place varStatus in the Default value,  I get a "The property expects Table values, but this rule produces incompatible Text values."  Keep in mind that the "Status" field is a lookup column in SharePoint, and I need to do the following:

 

1.  When a new form loads (MyForm.Mode=FormMode.New0, I need to set the Status field to show "New."

2.  When I click the SUBMIT button, I need to update that field to "Submitted."

 

So I'm thinking that varStatus has to be some sort of lookup to the choice column where we filter it to Value=New, but I can't quite get that working either.  I placed the formula below in the Default value for the Status column and the Status field still is empty when I open a new form:

 

If(
    MyForm.Mode = FormMode.New,
    LookUp(
        Choices('ListName'.'Status'),
        Value = "New"),
    Parent.Default)

 

One other thing I mentioned - the field is currently in View mode.  Could that be the issue?

 

 

 

 

blanghorst
Level: Powered On

Re: Field update as part of submit rule

I got it working.  Here is what I did so far:

 

1.  On the status field, I changed the field to "Edit Lookup" from "Edit Selection" (not 100% sure if it was necessary).

2.  On the default value for the Status field, I entered:  If(IsBlank(varStatus),Parent.Default,varStatus)

3. On the Submit button, I entered:

 

UpdateContext({varStatus:LookUp(Choices('ListName'.'Status'),Value = "Pending")});SubmitForm(SharePointFormName)

 

Now, when I submit my form, it changes the status to "Pending" upon submission exactly how I wanted.

 

Thanks!

Community Support Team
Community Support Team

Re: Field update as part of submit rule

Hi @blanghorst,

Have you solved your problem?

Based on the needs that you mentioned, I think it is not necessary to change the Status field (Combo Box) control from "Edit selection" to "Edit Lookup". In addition, it is also not necessary to initialize a variable to store the Status value.

I have made a test on my side, please take a try with the following workaround:6.JPG

 

7.JPG

Set the DefaultSelectedItems property of the Combo Box control within the Status Data card to following:

If(
    SharePointForm1.Mode=FormMode.New,
    {
        Value:"New"
    },
    Parent.Default
)

Set the OnSave proeprty of the SharePointIntegration control to following:

SubmitForm(SharePointForm1)

Set the OnSuccess property of the SharePointForm1 control to following:

Patch(
'20181130_case3',
SharePointForm1.LastSubmit,
{
Status:{Value:"Pending"}
}
);
ResetForm(SharePointForm1);
RequestHide()

On your side, you should type:

Patch(
    'YourSPList',
     SharePointForm1.LastSubmit,
     {
       Status: {
Value: "Pending"
} } ); ResetForm(SharePointForm1);
RequestHide()

Please take a try with above solution, check if it help solve your problem.

If you have solved your problem, please go ahead and click “Accept as Solution” so that this thread will be marked for other users to easily identify.

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
blanghorst
Level: Powered On

Re: Field update as part of submit rule

To be clear, mine is a dropdown list populated by a choice column in SharePoint.   It would've been easier had the person who built the list just made the Status field a text box because no one will ever actually manually specify a status.  Thanks for the information below, however - I will definitely take a look and keep it in mind.  I did get mine working per my previous post with only one little glitch, but it isn't important for me to resolve it at the moment.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (5,583)