cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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 Resident Rockstar
Resident Rockstar

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.

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
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

‘Better Together’ T-Shirt Contest – Winner Announced!

‘Better Together’ T-Shirt Contest – Winner Announced!

And the winner is...

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Power Platform 2020 release wave 1 plan

Power Platform 2020 release wave 1 plan

Features releasing from April 2020 through September 2020

Top Solution Authors
Top Kudoed Authors
Users online (6,713)