cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Activating the flow in OnSuccess before the form reset its default values

I have SharePoint list which is updated through PowerApps.

I have an edit form which either created new records or edits existing records.

I have a fairly simple flow: PowerApps -> Mail (it asks for To:, Subject:, Body:, and CC: in PowerApps)

In the form I have a field which is Manager (in SharePoint list its People/Group field)

Here is the formula for ManagerField Default property:

If(
    FormType="Edit",
    ThisItem.FirstApprover,
    {
        '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
        Claims:Concatenate("i:0#.f|membership|",Manager.Mail),
        Department:Manager.Department,
        DisplayName:Manager.DisplayName,
        Email:Manager.Mail,
        JobTitle:Manager.JobTitle,
        Picture:""
    }
)

 

FormType is context variable and it is either Edit (for when the people are editing an record) or New for when people are creating record.

So, when people are editing a record, the Manger field populates with what is already set. If this is a new record, the filed populates with Manager variable (which is a collection and takes info from Office365.Users).

I want to send an email after there has been an edit or new record was created. So, on the EditForm OnSuccess property I have this function:

 

 

If(
    FormType="New",
    'TravelRequestAPP-Version2'.Run("MYEMAIL@MYCOMPANY.COM","TEST NEW",ManagerField.Selected.Email," MYEMAIL@MYCOMPANY.COM ");
    Navigate(MyTravelRequestList,ScreenTransition.Fade,{SuccessMessage:"New Request Created"}),
    'TravelRequestAPP-Version2'.Run("MYEMAIL@MYCOMPANY.COM","TEST MODIFY",ManagerField.Selected.Email," MYEMAIL@MYCOMPANY.COM ");
    Back()
)


So basically, if the form is for new record it sends email to my email, with subject TEST NEW, with body of ManagerField Email and CC to my email, and moves to a page where all requests are displayed. If its edit it send email to my email with TEST MODIFY as subject and Manager email.

 

So it all works and I receive the email. However if the user changes the Manager on the New record creation (changes the default manager) and then Submits the form when the OnSuccess fires ManagerField.Selected.Email resets to the default value not the one entered by the user.

 

 

How would you guys activate this flow before the form puts back default values? I could put the flow on the Submit button but then if the record is not created it would still send an email that’s why I wanted to put it on OnSuccess. Is there any way to restrict the form to resetting to default values before OnSuccess function fires, or somehow capture the value user put in before it is reseted to default value?

 

3 REPLIES 3
Community Support Team
Community Support Team

Re: Activating the flow in OnSuccess before the form reset its default values

Hi MartynasJurkus,

 

What’s your current situation?

 

I assume that your flow is triggered by a PowerApps button. Per my understanding, once the form is submitted, the form will put back its default value, so when OnSuccess fires the field will reset to the default value but not the one entered by user.

 

When you put the flow on the submit button, how did you configure the code?

 

What kind of record do you want to submit to data source? Not sure if you could consider to combine IF function or others to restrict the data submitted to data source.

 

Best regards,
Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Re: Activating the flow in OnSuccess before the form reset its default values

Hi @v-yamao-msft

 

I found a work around which I use for now. On the submit button OnSelect I setup a context variables for each user input. If the form is submitted successfully, in the OnSuccess property I use the context variables which do not reset.

 

Also I do not know if this is posible but maybe there could be a return value when the form is submitted successfully to use like ThisItem with the recently added item, so PowerApps would assign ThisItem to the newly created record in a SharePoint list. Maybe an idea to consider for the future.

Highlighted
cortexeo
Level: Powered On

Re: Activating the flow in OnSuccess before the form reset its default values

Hi @Anonymous

 

I had the same issue. I generally wanted to compare the value of what was being submitted vs. what the current value was. If the values were different, I would run the flow to update the record.

 

I used SharePointIntegration1.Selected.FIELDNAME to get the current value and the DataCardValue to get what was being submitted. I had to use the Set() function to store these in the onSave trigger, and it had to run before the SubmitForm() ... Is this essentially how you did it or did you figure out something different?

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
Users Online
Currently online: 171 members 5,242 guests
Please welcome our newest community members: