cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Spawn10
Helper II
Helper II

Is it possible to have two 'Patch' statements in a submit button?

Is it possible to have two 'Patch' statements in a submit button? I have a button that is performing an update. Someone else built this, and I am coming behind to add one more functionality. I have added an additional 'Patch', but it is not working or throwing any errors.

ForAll(AttachmentsSelect.SelectedItems,Collect(Attachments,{Value:Call})); Collect('My List',{Account_x0020_Number:EntityIDInput.Text,Title: AccountNameInput.Text,Client_x0020_Name: ClientSelect.Selected.Name,Client_x0020_Email:ClientEmailInput.Text,Firm_x0020_ID:FirmIDInput.Text,Ivestment_x0020_Strategy:InvestmentStrategyInput.Selected.Value,Select_x0020_Attachments:Attachments});If(_seqItem = "New",Collect(EntityId,{Title: _myProfile.Id,Sequence: _seqNum}),Patch(EntityId,LookUp(EntityId,Title = _myProfile.Id),{Title: _myProfile.Id,Sequence: _seqNum}));Patch('My List', First(Filter('My List',ID = OpenItems.Selected.ID)), {Status: StatusDropDown.SelectedText});

What am i doing wrong here?

1 ACCEPTED SOLUTION

Accepted Solutions
mdevaney
Super User III
Super User III

@Spawn10 

Yes, you can have 2 patches in 1 button.

 

If the patch does not update any records and also does not result in an error your first assumption should be that no record was found to patch.  See the code below in bold.

 

Patch(
'My List',
First(Filter('My List',ID = OpenItems.Selected.ID)),
{Status: StatusDropDown.SelectedText}
);

 

To test, make a new button and put the following code in the OnSelect property.

 

ClearCollect(myTest,First(Filter('My List',ID = OpenItems.Selected.ID)))

 

Now create a new table and use myTest as the datasource.  Were any records returned?  If none were returned, this code segement is the source of your issue.

 

---
Please click "Accept as Solution" if my response helped to solve your issue so that others may find it more quickly. If your thought the post was helpful please give it a "Thumbs Up."

View solution in original post

1 REPLY 1
mdevaney
Super User III
Super User III

@Spawn10 

Yes, you can have 2 patches in 1 button.

 

If the patch does not update any records and also does not result in an error your first assumption should be that no record was found to patch.  See the code below in bold.

 

Patch(
'My List',
First(Filter('My List',ID = OpenItems.Selected.ID)),
{Status: StatusDropDown.SelectedText}
);

 

To test, make a new button and put the following code in the OnSelect property.

 

ClearCollect(myTest,First(Filter('My List',ID = OpenItems.Selected.ID)))

 

Now create a new table and use myTest as the datasource.  Were any records returned?  If none were returned, this code segement is the source of your issue.

 

---
Please click "Accept as Solution" if my response helped to solve your issue so that others may find it more quickly. If your thought the post was helpful please give it a "Thumbs Up."

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (3,203)