cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper II
Helper II

Adding Items to gallery list from dropdown selection with button.

I'm trying to add items selected from three dropdown lists to a gallery list after I hit an add button. The image attached below is what I'm shooting for it to look like. I've been trying to figure this out for ages and I can't find anything to assist me. 

 

Essentially I have three drop-down menus. Business Type, Line of Business, and RBC Type. I want to be able to select the entries I want from the drop downs and then add those values to a list when I hit an add button. There is also a clear button underneath the add button to clear the list.

 

The other requirement for this is that there needs to be at least 1 item in the list but no more than 5 items total. I'm at my wit's end trying to figure this out I'm really hoping someone could offer a solution for me.

 
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Hi!

 

Ok, so it´s one record per Add click. So, I guess the easiest way is to create a Collection when pressing the Add button and the use the Collection as datasource to the gallery. 

  1. On the "OnSelect" property of the Add button, add below formula. This will create one record in a collection called DropDownListCol containing all three dropdown values. You may need to change the names for the Dropdowns to the names in your app.

 

Collect(DropDownListCol,{BusinessType:Dropdown1.SelectedText.Value,LineOfBusiness:Dropdown1_1.SelectedText.Value,RBCType:Dropdown1_2.SelectedText.Value})​

 

  • For the Gallery, on the "Items" property enter DropDownListCol. 
  • You also need to add three labels within the gallery to show the values. For each label, set the "Text" property to ThisItem.RBCType (ThisItem.BusinessType etc).
  • For the Clear button, add below formula to clear the selections.

 

Clear(DropDownListCol)​

 

Hope this helps 🙂

 

BR

Pontus

View solution in original post

7 REPLIES 7
Highlighted
Resolver IV
Resolver IV

Hi!

 

Question; when you hit the Add button, do you want to create one record with three columns or three records with one column? Also, which datasource are you using for the gallery? External or is it just a collection?

 

BR

Pontus

Highlighted

So with the dropdowns, I just want to take the entires (from the photo as an example 'Aviation', 'Ordinary Life', and 'IMM') and add them all on one line in a gallery. So I guess one column one row per add button. If it would be easier to do 3 columns one row per add button then I could do that too. I'm not exactly sure what you mean by the data source as I am new to power apps but for right now I don't have either set up I believe. 

Highlighted

Hi!

 

Ok, so it´s one record per Add click. So, I guess the easiest way is to create a Collection when pressing the Add button and the use the Collection as datasource to the gallery. 

  1. On the "OnSelect" property of the Add button, add below formula. This will create one record in a collection called DropDownListCol containing all three dropdown values. You may need to change the names for the Dropdowns to the names in your app.

 

Collect(DropDownListCol,{BusinessType:Dropdown1.SelectedText.Value,LineOfBusiness:Dropdown1_1.SelectedText.Value,RBCType:Dropdown1_2.SelectedText.Value})​

 

  • For the Gallery, on the "Items" property enter DropDownListCol. 
  • You also need to add three labels within the gallery to show the values. For each label, set the "Text" property to ThisItem.RBCType (ThisItem.BusinessType etc).
  • For the Clear button, add below formula to clear the selections.

 

Clear(DropDownListCol)​

 

Hope this helps 🙂

 

BR

Pontus

View solution in original post

Highlighted

@pontusofsweden 
I believe that will help, just one question: what do you mean by adding labels to the gallery? Like a text label from the insert tab? or something under properties? Edit: also how would I limit that list to just 5 items and require it to have at least one item before the form is submitted?

Highlighted

Hi,

yes, a text label from the Insert Tab

 

BR

Pontus

Highlighted

@pontusofsweden Okay thank you, you've been a world of help! I just need to figure out how to limit the number of entries to 5 and require at least 1.

Highlighted

To limit the entries, you can just adjust the OnSelect property of the Add button to only add records if the total amount of rows in your collection is less than 5:

If(CountRows(DropDownListCol) < 5;Collect(DropDownListCol{BusinessType:Dropdown1.SelectedText.Value;LineOfBusiness:Dropdown1_1.SelectedText.Value;RBCType:Dropdown1_2.SelectedText.Value}))

 

Not sure what you mean with at least 1. To be able to do what? Anyway, you can use a similar If statement as above but check that the ampunt of rows is larger than 0. Like:

If(CountRows(DropDownListCol) > 0)

 

BR

Pontus

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (9,721)