cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Rohit03
Regular Visitor

Multiple selected values not getting stored in CDS

Hi,

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.

 

Thanks.

 

3 REPLIES 3
Ionaaa
Helper II
Helper II

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 🙂

Rohit03
Regular Visitor

I have tried using for all function but it only store single values. Here is the formula.

ForAll(galleryTopics.AllItems,Relate(galleryTopics.Selected.Courses,_LastCourseGuid))

can you please review it, whether I have applied the formula correctly.

 

Thanks

Ionaaa
Helper II
Helper II

Let's say that you have two galleries with selected items, Gallery1 and Gallery2.

The button should start with the following logic:

Clear(Gal1);
Clear(Gal2);

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.

Helpful resources

Announcements
October Events

Mark Your Calendars

So many events that are happening this month - don't miss out!

Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Top Solution Authors
Top Kudoed Authors
Users online (3,139)