cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
kriggo15
Post Patron
Post Patron

Need help with Patch function

I have a collection (NavigationTest) that I'm using for Navigation (imagine that). It allows a user to select a Service via dropdown, then for each option tied to that Service, when the user clicks "Go" it should set the Navigate column to true. The gallery on the far left is just there for testing purposes.

patchss2.png

 

I'm getting an invalid argument error on my patch function. What am I doing wrong?

patchss1.png

1 ACCEPTED SOLUTION

Accepted Solutions
mdevaney
Super User III
Super User III

@kriggo15 

OK, then you could use UPDATEIF instead of PATCH to edit multiple records based on some condition.

UpdateIf(
    NavigationTest,
    Service=Dropdown1_1.Selected.Result,
    {Navigate: true}
)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

5 REPLIES 5
mdevaney
Super User III
Super User III

@kriggo15 

This section of code is failing because PATCH wants to know which record you want to edit.  FILTER returns multiple records but you only want to edit a single record.

 

Filter(NavigationTest,Service=Dropdown1_1.Selected.Result)

 

Replace it with this code instead.  Make sure to use your Table name instead.

 

DataTable1.Selected

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

@mdevaney  Actually I want each record tied to the service to be true. So if I select Service3, like the screenshot, it should set Option 4, Option5, and Option6, as true for Service3.

mdevaney
Super User III
Super User III

@kriggo15 

OK, then you could use UPDATEIF instead of PATCH to edit multiple records based on some condition.

UpdateIf(
    NavigationTest,
    Service=Dropdown1_1.Selected.Result,
    {Navigate: true}
)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

@mdevaney 

Thanks, guess I didn't realize that Patch would only do the 1 record. Thought it would do each for the specific Service. Appreciate your help!

@kriggo15 

PATCH can be used to change more than one but you  have to combine it with another function called FORALL.

 

UPDATEIF basically does the same thing as PATCH + FORALL but its shorter to write 🙂

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (40,849)