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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / OnSave - Choosing a di...
Power Apps
Answered

OnSave - Choosing a different form to submit based on a field value

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I am customising sharepoint list forms with powerapps, and have different new, edit and view screens and forms set up.  This is to move through an approval process.

 

I actually have several different edit screens and forms as we move through the approval process. I have figured out how to get the different Edit form to show based on the Status value, no problems!

 

OnEdit

If(SharePointIntegration.Selected.Status.Value = "New", EditForm(FormCoordinatorReview); Navigate(ScreenCoordinatorReview,ScreenTransition.None), EditForm(FormMasterEdit); Navigate(ScreenMasterEdit, ScreenTransition.None))

Now I want to be able to save the correct form based on the current screen or form, whatever works. I started of with this:

 

OnSave

If(SharePointFormMode="CreateForm", SubmitForm(FormNewSubmit), If(SharePointFormMode="EditForm", SubmitForm(FormMasterEdit)))

Is there a variable for the current screen or form I can pull through? eg: If(This.Screen = "ScreenCoordinatorReview", SubmitForm(FormCoordinatorReview), do something else)

 

Or do I need to add some hidden control on my form that says eg: CurrentStep, then grab this value in OnSave?

 

Or something else?  Or not possible?

Categories:
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    I would say that you could use the same logic on your OnSave:

     

     

    Switch(SharePointIntegration.Selected.Status.Value,
    "New", SubmitForm(FormCoordinatorReview),
    SubmitForm(FormMasterEdit)
    )

    You're already determining which EditForm to display with the Status.Value, so why not use that in your Save?

    By the way, I also substituted the Switch function in the above as you will probably have other conditions to check against down the road, and this will be cleaner than nested If statements.

     

    I hope that is helpful for you.

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Ah excellent, can use Switch in powerapps (still learning obviously!)

     

    So, my issue with using the Status value is that I want people to be able to partially fill the data and save without pushing it to the next stage... so there is a few things I need to figure out... when and how do I update the status when we are ready to move on etc.

     

    Just with some placeholders below while i try and figure out what code/syntax can be used in PowerApps... could something like this work?

    Switch(SharePointIntegration.Selected.Status.Value,
    "New",
    If(someCheckboxToMoveOn=checked/true, Set(Status.Value, "Marketing Review"));
    SubmitForm(FormCoordinatorReview),
    SubmitForm(FormMasterEdit)
    )

        

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Here is what I came up with, however it does not upate the status

     

    If(SharePointFormMode="CreateForm", SubmitForm(FormNewSubmit), 
     If(SharePointFormMode="EditForm", 
     Switch(SharePointIntegration.Selected.Status.Value,
     "New", If(SendForMarketingReview.Value=true, Set(Status,"Marketing Review")); SubmitForm(FormCoordinatorReview),
     SubmitForm(FormMasterEdit) 
     )
     )
    )
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I've also tried the following, no joy:

     

    If(SharePointFormMode="CreateForm", SubmitForm(FormNewSubmit), 
     If(SharePointFormMode="EditForm", 
     Switch(SharePointIntegration.Selected.Status.Value,
     "New", If(SendForMarketingReview.Value=true, Set(Status, { value: "Marketing Review" } )); SubmitForm(FormCoordinatorReview),
     SubmitForm(FormMasterEdit) 
     )
     )
    )
  • v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

    Could you please share a bit more about your scenario?

    Do you want to update the Status column value within your SP List? Is the Status column a Choice type column in your SP list?

     

    According to the needs that you mentioned, I suppose that you want to update the Status column value within your SP List, and the Status column is a Choice type column, is it true?

     

    Based on the formula you provided, I think there is something wrong with it. If you want to update the Status column value within your SP List, I think the Patch function could achieve your needs.

    I have made a test on my side, please consider modify your formula as below:

    If(
    SharePointFormMode = "CreateForm",
    SubmitForm(FormNewSubmit), If(
    SharePointFormMode = "EditForm", Switch(
    SharePointIntegration.Selected.Status.Value, "New",
    If(
    SendForMarketingReview.Value=true,
    Patch( /* <-- Modify your formula here */
    'YourSPList',
    LookUp('YourSPList', ID = SharePointIntegration.Selected.ID),
    {
    Status: {
    Value: "Marketing Review"
    }
    }
    )
    );SubmitForm(FormCoordinatorReview), SubmitForm(FormMasterEdit) ) ) )

    Or

    If(
    SharePointFormMode = "CreateForm",
    SubmitForm(FormNewSubmit), If(
    SharePointFormMode = "EditForm", Switch(
    SharePointIntegration.Selected.Status.Value, "New",
    If(
    SendForMarketingReview.Value=true,
    Patch( /* <-- Modify your formula here */
    'YourSPList',
    SharePointIntegration.Selected,
    {
    Status: {
    Vlaue: "Marketing Review"
    }
    }
    )
    );SubmitForm(FormCoordinatorReview), SubmitForm(FormMasterEdit) ) ) )

    Please consider take a try with above solution, then check if the issue is solved.

     

    More details about the Patch function, please check the following article:

    Patch function

     

    Best regards,

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Yes, Status is a Choice column.

     

    My form has many fields (but not all the columns of the list).  These should be able to be updated and saved at any time (it may take some time for the user to collect all the required information).

     

    When the information has been completed, I want to update the Status but I dont want to display the field on the form (the person may select the wrong status as the next step).  My "solution" to this is to have the checkbox, when selected it indicates we are ready to move on to the next step.

     

    I havent used Patch before, but my understanding is that it is used to update specfic columns (asyncronously?), rather than a whole form? Would you normally use patch to update one value, then SubmitForm to update more in the same list?

  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    Yes, trying to set a field like that is not allowed.  You need to look at it from another perspective.  In PowerApps controls and fields and such all "derive" their values from other places rather than through assignment (like if it was a development language).

     

    What I would recommend is to instead look at the Default and/or Update properties of the Status column DataCard in your EditForm.

    First, you indicate you don't want it to be displayed.  This is easily done by setting the Visible property of the datacard to false.

    Then, for the Update property for the datacard, you will want to set the value based on your conditions.

    So, let's say you have a CheckBox on your Screen for "Complete, Send to Marketing" called chkCompleteForMarketing

    In this case, you can have in your Update property for the datacard for the Status column the following formula:

       If(chkCompleteForMarketing.Value, {Value: "Marketing Review"})

    When the form is submitted, if the box is checked, then the Status column value will change/update to the value above.

    That should do what you need.  No Patching needed.  

    Also, you would do this on each EditForm you have for different stages of your record...which you will want to base off of a different check box for that stage.

     

    As for your OnSave, I'm not sure of all your status values and form names, so I will improvise a little, and that would still simply be the following:

     

    Switch(SharePointIntegration.Selected.Status.Value,
     "New", SubmitForm(FormCoordinatorReview), //Note, this form would have the above formula for the status
     "Marketing Review", SubmitForm(FormMarketingReview), //Note: assuming there is such a form for marketing review
    "Management Review", SubmitForm(FormManagmentReview), //Note: assuming this status as an example
    SubmitForm(FormMasterEdit) )

    Make sure all the above correspond to your actual exact Status value choices and that use use those same exact values for the Update properties of your Edit forms.

     

    See how that works out for you and post back with any questions.

     

     

     

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks so much @RandyHayes , that did it!

     

    On to the next problem 🙂

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 232 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 202 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 122

Last 30 days Overall leaderboard