cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SkiDK
Solution Sage
Solution Sage

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
yashag2255
Dual Super User II
Dual Super User II

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!

View solution in original post

2 REPLIES 2
yashag2255
Dual Super User II
Dual Super User II

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!

View solution in original post

@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
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!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (1,608)