cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

Update Status field from Draft to Submitted after submitting the form

Hello,

I have multiple screens/forms using one sharepoint list. On the last screen, there is a Save button and also a form let's call it as Form3 with a choice field called Status. Form3 is view only mode and the Status field is blank. The Status drop down options are Draft, Submitted, Approved. I want the Status field to default to Draft before submitting the form through Save button. and once you hit the Save button, the Status field should be changed to Submitted. So far, I have the below code.

  1. OnStart

 

Set(
    VarStatus,
    "Draft"
)​

2. DefaultSelectedItems on Form3 Status field property

 

 

LookUp(
    Choices('SharePointList'.Status),
    Value = VarStatus
)​

3. OnSelect on Save button

 

 

Set(
    id2,
    Patch(
        'SharePointList',
        Defaults('SharePointList'),
        Form1.Updates,
        Form2.Updates,
        Form3.Updates
    ).ID
);
Set(
    VarStatus,
    "Submitted"
);
Notify("Form submitted successfully");​

 

This works for most part. Where it doesn't work is, when I go back to edit the request, on screen3 form3, , the status is still Draft instead of Submitted

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Hi @PoojaG :

I've made a similar test 

I did a test, and I found that the problem you mentioned sometimes appears and sometimes does not appear. I guess this may be caused by the delay.

So I suggest you add time delay between formulas(I used this method to completely solve the problem)

The point is using a timer control instead of the button(You can jump directly to Step5)

1\My data source(List1)

TitleSingle line of text
MutipleMultiple lines of text
LookupFieldLookup
YourPersonColumnPerson or Group
StatusChoice

2\Create a new app and set it's OnStart property to:

 

Set(
    VarStatus,
    "Draft"
)

 

3\Add a form (Form3)

DataSource

 

List1

 

DefaultMode

 

FormMode.New

 

4\set the combox's DefaultSelectedItems proeprty to:

 

LookUp(
    Choices(List1.Status),Value=VarStatus
)

 

2.JPG

5\Add a Timer control

OnSelect

 

Set(
    VarStatus,
    "Submitted"
);

 

Duration

 

2000 /*Delay 2 seconds*/

 

OnTimerEnd

 

Set(
    id2,
    Patch(
        List1,
        Defaults(List1),Form2.Updates,Form3.Updates
    ).ID
);

Notify("Form submitted successfully")

 

Text

 

"Submit"

 

76.gif

Best Regards,

Bof

View solution in original post

4 REPLIES 4
Highlighted
Community Support
Community Support

Hi @PoojaG :

Firstly,let me explian why the status is still Draft instead of Submitted.

The key is the execution order of the formula.

From the formula you provided, the variable VarStatus was changed to "Submitted" after Form1/2/3 was submitted. So the status cannot be changed to "Submitted".

Secondly,I suggest you adjust the execution order of the following formulas:

 

Set(
    VarStatus,
    "Submitted"
);
Set(
    id2,
    Patch(
        'SharePointList',
        Defaults('SharePointList'),
        Form1.Updates,
        Form2.Updates,
        Form3.Updates
    ).ID
);
Notify("Form submitted successfully");​

 

Best Regards,

Bof

Highlighted

@v-bofeng-msft thank you for your response. That makes sense. I changed the order of the code, but the status remains Draft even on the sharepoint list. 

Highlighted

Hi @PoojaG :

I've made a similar test 

I did a test, and I found that the problem you mentioned sometimes appears and sometimes does not appear. I guess this may be caused by the delay.

So I suggest you add time delay between formulas(I used this method to completely solve the problem)

The point is using a timer control instead of the button(You can jump directly to Step5)

1\My data source(List1)

TitleSingle line of text
MutipleMultiple lines of text
LookupFieldLookup
YourPersonColumnPerson or Group
StatusChoice

2\Create a new app and set it's OnStart property to:

 

Set(
    VarStatus,
    "Draft"
)

 

3\Add a form (Form3)

DataSource

 

List1

 

DefaultMode

 

FormMode.New

 

4\set the combox's DefaultSelectedItems proeprty to:

 

LookUp(
    Choices(List1.Status),Value=VarStatus
)

 

2.JPG

5\Add a Timer control

OnSelect

 

Set(
    VarStatus,
    "Submitted"
);

 

Duration

 

2000 /*Delay 2 seconds*/

 

OnTimerEnd

 

Set(
    id2,
    Patch(
        List1,
        Defaults(List1),Form2.Updates,Form3.Updates
    ).ID
);

Notify("Form submitted successfully")

 

Text

 

"Submit"

 

76.gif

Best Regards,

Bof

View solution in original post

Highlighted

@v-bofeng-msft wow I appreciate it so much you going above and beyond for solving the problem. This solution worked perfectly. thank you so much!

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (8,115)