cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
SkiDK
Level 8

Get access to elements in a gallery

In a SQL database I have stored several items to display in a gallery, which works. These items are shown as checkboxes, that when these are displayed and one is checked, the Id from that checkbox gets linked with another record in the database.

 

My next step is to patch all the checked (add) and unchecked (delete) boxes to the database. But since this is a gallery, I can't access the Id from these checkboxes. Is there a way to get the specific checkbox from a specific item so that I can store it in the correct place in the database?

 

Thank you very much

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Get access to elements in a gallery

Hi @SkiDK 

 

You can use a ForAll loop to iterate over all the gallery items, and accessing the value for each item individually:
ForAll(Gallery1.AllItems, If(Checkbox1.Value = false, Remove(DataSource, <<Condition>>), Patch(DataSource,Defaults(DataSource),{Status: Checkbox1.Value})))
Here we are iterating over each gallery item and checking if the checkbox is checked or not, if it is not checked, the item will be removed, else it will patch the record. Please update the actual control names in the formula along with the specific condition to perform operations.

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

2 REPLIES 2
Super User
Super User

Re: Get access to elements in a gallery

Hi @SkiDK 

 

You can use a ForAll loop to iterate over all the gallery items, and accessing the value for each item individually:
ForAll(Gallery1.AllItems, If(Checkbox1.Value = false, Remove(DataSource, <<Condition>>), Patch(DataSource,Defaults(DataSource),{Status: Checkbox1.Value})))
Here we are iterating over each gallery item and checking if the checkbox is checked or not, if it is not checked, the item will be removed, else it will patch the record. Please update the actual control names in the formula along with the specific condition to perform operations.

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

SkiDK
Level 8

Re: Get access to elements in a gallery

@yashag2255 

Thanks, you helped very much. Was a bit searching with linking to the correct items in the database, but basically it worked.

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Next Wednesday, August 21st at 8am PDT

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

SixthImage

Power Summit Australia 2019

August 20-23rd 2019

Users Online
Currently online: 22 members 4,381 guests
Please welcome our newest community members: