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

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

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

Super User
Super User

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

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
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (50,490)