Showing results for 
Search instead for 
Did you mean: 
Frequent Visitor

Set value of checkbox in a Gallery Item with ForAll

Hi All,


I have been battling with this problem for a day with no success so far.  I'll put my problem into context:


- I have created two entities in the CDS named "Task" and "Task template". Their relation is Many to Many, so different tasks can belong to the same template, and different templates can reference the same task. 

- I have created a combox box that displays the name of the template, and I have created a Gallery listing the Tasks.. I have inserted a checkbox to the gallery.


My goal is that when clicking a button called "Add template", the checkbox of the corresponding task is set to true (later on I want to use this checkbox to know what tasks I have to include in another table entity).


So, the code of the "Add template" button is the following: 


       TemplateCombo.SelectedText.Value in Gallery1.Selected.'Task template'.'Task template name';
       Gallery1.Selected.Checkbox3.Value = true;
       Gallery1.Selected.Checkbox3.Value = false


But nothing happens. I'm thinking maybe the Gallery1.Selected can not be used. Any ideas?


Thanks in advanced.


Hi v-siky-msft, thank you again for your response.


I tried the solution you gave me, but I can't use "TemplateCombo.Selected.Value". The "Value" part throws an error because it doesn't appear in the displayed selectable fields. What is "Value" exactly? I get that TemplateCombo.Selected is the whole register (row) and I can select a field like TemplateCombo.Selected.FieldX, but I don't get what Value can be.




However, I could tweak it a little bit, and in the end I did the following:


Button.OnSelect = Set(MyTemplateComboVar;MyTemplateComboVar & ";" & TemplateCombo.Selected.'Task template name')


Checkbox.Default = !IsEmpty(Filter(ThisItem.'Task template'.'Task template name'; 'Task template name' in MyTemplateComboVar))


And that worked perfectly. I added a button to reset al tasks.


Thank you so much for you help throughout this thread. I'll accept your post as the Solution 🙂 !


Helpful resources

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Apps Ideas

Check out the New Ideas Site

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (4,859)