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

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

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

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

@Sandie 

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.

 

 

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
8 REPLIES 8
Super User
Super User

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

@Sandie 

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.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Sandie
Level: Powered On

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

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)
)

    

Sandie
Level: Powered On

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

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) 
        )
    )
)
Sandie
Level: Powered On

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

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) 
        )
    )
)
Community Support Team
Community Support Team

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

Hi @Sandie ,

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 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.
Highlighted
Sandie
Level: Powered On

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

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?

Super User
Super User

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

@Sandie 

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.

 

 

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Sandie
Level: Powered On

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

Thanks so much @RandyHayes , that did it!

 

On to the next problem Smiley Happy

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

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

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 192 members 5,558 guests
Recent signins:
Please welcome our newest community members: