I have two tables named as Courses(parent) and Topics which have a relationship of many to many in CDS. I have used gallery and inside a gallery I have used checkbox to display Topic values that is fetch from cds. Now what I want is that, on click of a button I want all the checked values of a checkbox to be stored in the Topic entity, but I am only getting the last selected checkbox values even though I have selected multiple values. I am using relate function and I am unable to use collection in a relate function.
Any solutions on how to pass and store all the selected values of checkbox in the cds using relate function.
Your logic indeed relates one selected topic with one selected certification. If you need to relate multiple records at once, you need to use the ForAll functionality and loop through all items that are selected to relate them 🙂
I have tried using for all function but it only store single values. Here is the formula.
can you please review it, whether I have applied the formula correctly.
Let's say that you have two galleries with selected items, Gallery1 and Gallery2.
The button should start with the following logic:
Now, I want to gather all the selected items from Gallery1 into Gal1.
ForAll( Gallery1.AllItems, If( ThisRecord.Checkbox1.Value = true, Collect( Gal1, ThisRecord ) ) );
Same for Gallery2:
ForAll( Gallery2.AllItems, If( ThisRecord.Checkbox2.Value = true, Collect( Gal2, ThisRecord ) ) );
Now to walk through both sections to relate left to right:
ForAll( Gal1 As G1, ForAll( Gal2, Relate( G1, ThisRecord ) ) );
Where G1 now would be your left gallery and ThisRecord refers to the second gallery you want to link.
So many events that are happening this month - don't miss out!
Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.
Your chance to join an engaging competition of Power Platform enthusiasts.