web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Reveal/hide menu trees...
Power Apps
Answered

Reveal/hide menu trees with StartsWith() within a collection patch

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I've been trying to use the following code to modify an existing collection, 'Col_Media_AirportData', so that it changes the value of 'ID' from 'false' to 'true' when the associated gallery item is selected. The aim is to show/hide subelements/subitems that share the element ID, eg:

 

1.1 should reveal 1.1.1, 1.1.2 etc

2.1 should reveal 2.1.1, 2.1.2 etc

 

I based the code on an online example by 6FootMedia LLC. The result of the original code (in green, below) was that the patch altered the ID value for anything containing the parent code, eg 1.1, eg 2.1.1. This understandably caused issues! The purpose of the new code is to change the value of 'ID' for the 'child' subelements that sit beneath the 'parent' elements. So 1.1, when selected, should reveal/hide 1.1.1, 1.1.2 etc.  Hence the idea of the 'startswith' condition is to force PowerApps to check that the item begins with the parent directory, and only reveals/hides those items. 

 

However, this does not work. The code shows no errors, but does not appear to be changing the values. What can I change to fix this? 

 

 

 

Select(Parent);
Patch(
 Col_Media_AirportData,
 Filter(
 Col_Media_AirportData,
 StartsWith(ThisItem.ID,ID)  //formerly ThisItem.ID in ID

&& ID <> ThisItem.ID ), ForAll( Filter( Col_Media_AirportData, StartsWith( ThisItem.ID, ID //formerly ThisItem.ID in ID ) in ID && ID <> ThisItem.ID ), If( ThisItem.Expanded, {Shown: false}, {Shown: true} ) ) ); Patch( Col_Media_AirportData, Filter( Col_Media_AirportData, ThisItem.ID = ID ), ForAll( Filter( Col_Media_AirportData, ThisItem.ID = ID ), {Expanded: !Expanded} ) )

 

 

Categories:
I have the same question (0)
  • Verified answer
    v-siky-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

     

    Do you want to filter out all items that items' ID start with thisitem ID in you first part of codes.

    I find something strange with your StartsWith function. The syntax is StartsWith( Text, StartText ), so the first parameter should be column you want to test, the second parameter is the text to search for at the beginning of column.

    So could you modify your two StartsWith functions as StartsWith(ID, ThisItem.ID) in you codes and try again to check if your issue is fixed.

     

    Best regards,

    Sik

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @v-siky-msft Fixed! After dealing with a few further typos, the code worked fine. Thank you very much for pointing out this silly error!

  • mdevaney Profile Picture
    29,991 Moderator on at

    @Anonymous 

    I am curious, what did you final product look like for the Reveal/Hide menu trees?  If you are able to share some screenshots I think it would be neat.

     

  • v-siky-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

     

    If that post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly.

     

    Best regards,

    Sik

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at
    Apologies Sik, I thought I had done that. I’ve checked and I’ve definitely clicked ‘accept as solution’ now-thank you once again.
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @mdevaney @v-siky-msft It's a work in progress, but here's what I've got so far. See attached.

     

     

    capture.PNG
  • mdevaney Profile Picture
    29,991 Moderator on at

    @Anonymous 

    That drill down gallery you made is very cool.  Maybe you could do a Community Blog article on it once you've got it perfected.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 214 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 185

Last 30 days Overall leaderboard