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

Add items selected from combo-box (lookup) to collection

Hello all,

 

I have a combo-box called 'reviewComboBox' (that contains items pulled from a Lookup column) inside my application. Some of the items are: January, February, March, April, May ... and so on.

 

My combo-box allows for multiple selections. I would like for: when the user selects multiple items and submits the form once they have made all their changes (ex: selecting what items they'd like, and de-selecting what they would not like if they change their mind), the items selected in that combo-box will be added together to a collection in the form of a table. Here's a visual of the collection I'd like if the 3 items:  'January' , 'February' , and 'March' are selected in the combo-box -->

jharville1_3-1605739701430.png

 

 

I have tried the following code in both the "OnSelect" and "OnChange" properties (in the 'Advanced Properties') section of my combo-box, but nothing is collected at all...                 Does anybody see any issue with my code?

 

jharville1_1-1605739640468.png

--------------------------------------------------------------

jharville1_2-1605739670662.png

 

(The reason why I'd like to implement a combo-box is because I'm building an 'Approvals' application. I already have it built (and functional) so that an approval is made on the entire form that is submitted... but I want to tweak the app so that it creates approvals for each of the items selected in the combo-box. The application: consists of one form with a combo-box section in it (and an input text field where the user inserts their name). I mentioned the combo-box holds items from a Lookup Field, which is from a SharePoint list that contains 2 columns. 1 column is for the Item Name (ex: January), and the 2nd column is a single line of text type that contains email addresses. Each item selection within the combo-box will route the form to a specific person --> ex: January emails (routes) the form to Jane Doe for approval of that 1 item (January), while February emails the form to Bob Smith and Dan Carr for approval of that 1 item (February). If both January and February are selected, all 3 of the users stated will be sent an email for approval of those 2 items (January and February).

 

I want to add selected items to the collection so that I can write code to count the number of items in the collection once the form is submitted, and then use a patch to create sub-approvals for each item in that collection for the submission.

 

Thank you!

 

 

2 REPLIES 2
Super User III
Super User III

@jharville1 

I actually answered your last post on this exact question, but it no longer seems to be available.  It might have accidentally been marked as spam, which means it will appear again after the moderators review and release.

 

Anyway, the answer I put there was, why bother with a collection?  The combobox will already be a collection of items in the SelectedItems property.  You can simply reference that in your formulas like this:

  reviewComboBox.SelectedItems

It will be a table/collection already with all the information you need.

 

If you still want the overhead of a collection in your app, you can set the collection as follows:

   ClearCollect(colReviewItems, reviewComboBox.SelectedItems)

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

Hi Randy,

 

I really do appreciate that second response. I did indeed get locked out of the original post and marked as spam for some reason haha, but I do see your reasoning for not having to create another collection as it would be repetitive of 'reviewComboBox.SelectedItems' .

 

I guess my reasoning in my head was to have that separate collection hold each of those items that were selected by the user, and use each of those items stored in that collection to create an approval for each item selected (by using a patch statement).

 

I have a quick question, would the 'reviewComboBox.SelectedItems' hold all the items in the combo-box once the form is submitted? I am thinking about what if a user selects 3 items (let's say "January" , "February", "March"), de-selects 2 of those items ("February" & "March"), and selects 4 different items ("April" , "May" , "June" , "July") ... would the collection hold what is most recently selected in the combo-box before the form is submitted after the changes have been made ("January" , "April" , "May" , "June" , "July") ? Or would it only take what was originally selected in the combo-box ("January" , "February", "March")? Or something else?

 

If I wanted the collection to contain the items currently in the checkbox (after all changes have been made but right before the form has been submitted), should I input the 'reviewComboBox.SelectedItems' in the OnSuccess property?

 

That's why I was originally thinking on inputting code within the 'onSelect' and 'onChange' properties of the combo-box; to collect what items are selected ('onSelect') and account for any changes made to the original selection before the form is submitted ('onChange').

 

Thank you so much for your help, I genuinely do appreciate it.

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (59,082)