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

How to combine 2 patch statements

Hey all!

I have a patch statement that unfortunately is causing my flow to trigger twice and was hoping you could help me roll it into a single statement to help eliminate the patch from my troubleshooting.


Context of what patch is doing.
First patch sets the old record in SQL to current flag false
Second patch sets the new record in SQL to approved, adds approval date, and sets the current flag of the record to true.

Here it is:

Patch(
'[dbo].[SoFriendly]',
First(
Filter(
'[dbo].[SoFriendly]',
Emp_Per_ID = Value(DataCardValue2.Text)
)
),
{Current_Flag: false}
);
Patch(
'[dbo].[SoFriendly]',
First(
Filter(
'[dbo].[SoFriendly]',
Emp_Per_ID = Value(DataCardValue1.Text)
)
),
{Payroll_Approval_Status: Payroll_Approval_Dropdown.SelectedText.Value, Payroll_Approval_Date: Date_Label.SelectedDate, Current_Flag: true}
);Navigate(Landing);Reset(Payroll_Approval_Dropdown);

1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

Re: How to combine 2 patch statements

I believe it is the following but will have to try tomorrow when I am back in the office.

 

Patch(
'[dbo].[SoFriendly]',
First(
Filter(
'[dbo].[SoFriendly]',
Emp_Per_ID = Value(DataCardValue2.Text)
)
),
{Current_Flag: false},

First(
Filter(
'[dbo].[SoFriendly]',
Emp_Per_ID = Value(DataCardValue1.Text)
)
),
{Payroll_Approval_Status: Payroll_Approval_Dropdown.SelectedText.Value, Payroll_Approval_Date: Date_Label.SelectedDate, Current_Flag: true}
);Navigate(Landing);Reset(Payroll_Approval_Dropdown);

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Re: How to combine 2 patch statements

I believe it is the following but will have to try tomorrow when I am back in the office.

 

Patch(
'[dbo].[SoFriendly]',
First(
Filter(
'[dbo].[SoFriendly]',
Emp_Per_ID = Value(DataCardValue2.Text)
)
),
{Current_Flag: false},

First(
Filter(
'[dbo].[SoFriendly]',
Emp_Per_ID = Value(DataCardValue1.Text)
)
),
{Payroll_Approval_Status: Payroll_Approval_Dropdown.SelectedText.Value, Payroll_Approval_Date: Date_Label.SelectedDate, Current_Flag: true}
);Navigate(Landing);Reset(Payroll_Approval_Dropdown);

View solution in original post

Eelman
Level 10

Re: How to combine 2 patch statements

Seems like your code is updating 2 different ID's in SQL, is this correct? If so, and your Flow is "when an item is created or modified", then it will run twice because you are making 2 modifications. If this is the case, try putting a condition in your Flow that stops this

 

Eg. if Current_Flag = false do nothing else do your Flow.

 

I don't think your second code bit will work? Haven't tested it, just doesn't look like it would.

Highlighted
Anonymous
Not applicable

Re: How to combine 2 patch statements

Yes updating two records in SQL.  The patch definitely works as is.  I could have as many patches as I want like that, as long as they all point to valid data sources and the data I'm plugging in matches, why not.

I will try and figure out how to stop flow based on your recommendation and report back.

Helpful resources

Announcements
Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

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

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Microsoft Business Applications Virtual Launch

Join us for the Microsoft Business Applications Virtual Launch Event on Thursday, April 2, 2020, at 8:00 AM PST.

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (9,893)