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

Create Collection of Items in Gallery Not Working

I have a simple table that has 3 vendors.

 

Vendor

100

200

300

 

I created a gallery with the vendor number and added a toggle box with a default value of "On".

 

I'd like to create a collection of all of the values that are checked but running into an issue.

 

On my button I have this formula:

rob26r_0-1604328411791.png

 

The formula works when all or none of the vendors are selected. 

 

However, when I change the toggle button on vendor 100 to "Off" my collection is not right - no items show up, see below.  I'm of course expecting to see vendor 200 & 300.

 

rob26r_1-1604328544232.png

 

I can't figure out why this is occurring?  What am I doing wrong?  Thanks.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-qiaqi-msft
Community Support
Community Support

Hi@rob26r,

Based on the issue that you mentioned, do you want to collect and remove the corresponding item once the Toggle value changes?

Could you please share a bit more about the scenario?

I agree with @rsaikrishna, the key is to the OnCheck and OnUncheck property of the Toggle. The formula you provided will always collect all the items within the Gallery.

I have a test on my side, please check the following workaround.

My data source is a collection named 'Table1' as below:

 

Collect(Table1,{Vendor:100},{Vendor:200},{Vendor:300})

 

I set the Text property of the Label within the Gallery as below:

 

ThisItem.Vendor

 

Set the OnCheck property of the Toggle as below:

 

Collect(VendorCollect,ThisItem)

 

Set the OnUncheck property of the Toggle as below:

 

Remove(VendorCollect,ThisItem)

 

Set the Items property of the DataTable as below:

 

VendorCollect

 

 

110302GIF.gif

Hope it could help.

Best Regards,

Qi

 

Best Regards,
Qi

View solution in original post

2 REPLIES 2
rsaikrishna
Community Champion
Community Champion

@rob26r 

 

Alternate solution:

 

The toggle control has OnCheck , OnUnCheck properties.

 

OnCheck - Collect the vendor number into the collection.

OnUncheck - RemoveIf the vendor number exists in the collection.

 

While the user performing the toggle ON/OFF, the collection will be filled in. So, you can directly use the collection.

 

Regards

Krishna Rachakonda

If this reply helped you to solve the issue, please mark the post as Accepted SolutionMarking this post as Accepted Solution, will help many other users to use this post to solve same or similar issue without re-posting the issue in the group. Saves a lot of time for everyone.

 

v-qiaqi-msft
Community Support
Community Support

Hi@rob26r,

Based on the issue that you mentioned, do you want to collect and remove the corresponding item once the Toggle value changes?

Could you please share a bit more about the scenario?

I agree with @rsaikrishna, the key is to the OnCheck and OnUncheck property of the Toggle. The formula you provided will always collect all the items within the Gallery.

I have a test on my side, please check the following workaround.

My data source is a collection named 'Table1' as below:

 

Collect(Table1,{Vendor:100},{Vendor:200},{Vendor:300})

 

I set the Text property of the Label within the Gallery as below:

 

ThisItem.Vendor

 

Set the OnCheck property of the Toggle as below:

 

Collect(VendorCollect,ThisItem)

 

Set the OnUncheck property of the Toggle as below:

 

Remove(VendorCollect,ThisItem)

 

Set the Items property of the DataTable as below:

 

VendorCollect

 

 

110302GIF.gif

Hope it could help.

Best Regards,

Qi

 

Best Regards,
Qi

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Carousel_PP_768x460_Wave2 (1).png

2022 Release Wave 2 Plan

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

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Top Solution Authors
Users online (3,731)