cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Cscox21
Frequent Visitor

Convert Patch function To UpdateIf

I have been following a Tree Hierarchy video (https://www.youtube.com/watch?v=qJv8IqqL01A&t=575s) to get some Collapsible/Expandable functionality but due to how the data is structured, we cannot use the Patch function. I have been led to the UpdateIf function and am struggling to figure it out. 

 

Here is the code that the video uses for Patch: 

Patch(
    TreeItems,
        Filter(TreeItems,ThisItem.Treepath in Treepath && Treepath<>ThisItem.Treepath),
        ForAll(Filter(TreeItems,ThisItem.Treepath in Treepath&&Treepath<>ThisItem.Treepath),
        If(ThisItem.Expanded,{Shown: false },{Shown: true }))
);
// Patch the parent node to indicate if it is expanded/collapsed
Patch(
    TreeItems,
        Filter(TreeItems,ThisItem.Treepath=Treepath),
        ForAll(Filter(TreeItems,ThisItem.Treepath=Treepath),
        {Expanded:!Expanded})
)

 

Here is my starting point for using the UpdateIf:

UpdateIf(AllRecords_values, (Filter('[dbo].[lut_Skills]', ThisItem.Expanded=true)), {Expanded:!Expanded});

 

The error i am getting is either Invalid Arguments or Expecting a boolean value if i change the last part to ThisItem.Expanded:! ThisItem.Expanded. 

 

Any tips/pointers/etc. is appreciated. I am not tied to any one function, I am just trying to get a tree hierarchy functionality. 

Thanks

14 REPLIES 14

I am actually using SQL database, not sharepoint. Still not working unfortunately. I do appreciate the help!

@Cscox21 ,

It is good practice to mention your data source when you post, or you may get responses that are not entirely focused on the problem. What type of field is Treepath?

Thank you for that advice. I am not entirely sure, it seems like a String data type/field but here is an snapshot of the collection: 

Cscox21_0-1620655920351.png

Because we are doing a hierarchy this (supposedly) helps with creating that tree structure. 

@Cscox21 ,

It seems to be multiple lines of text (I do not use SQL in Power Apps).

The issue is clearly this field due to the incompatible type error your are getting. You need to convert it into the field type that the query expects.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

Okay, i ended up getting the functionality I was looking for but it was in a totality different spot and unrelated to the Patch or UpdateIf. The Patch actually worked as intended but we were doing something with the gallery that didnt follow the video exactly. Regardless, thank you for the help!

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,037)