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}
)
)