web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Combobox selecteditem ...
Power Apps
Unanswered

Combobox selecteditem to a collection

(0) ShareShare
ReportReport
Posted on by

hi

 

I want to add/remove combobox selected items to a Collection. So it allow Multi Selection. 

Combox item property is from Office365Users and also I'm using PowerAutomate to get Employee ID which is not available from office365. So OnChnage property of the Combox i wrote the below code but it is only retaining one item. 

 

Set(StaffId,GetEmployeeId.Run(DataCardValue176.Selected.Mail));
ClearCollect(RequiredUser,{EmpID:StaffId.employeeid, FullName:DataCardValue176.Selected.DisplayName})

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @indhaa 

    You are issuing a ClearCollect on each change of the Combobox.  Thus you will only ever have one result from your flow.

     

    Your SelectedItems is already a collection/table of items.  Doing what you are doing on the OnChange will certainly slow down your app performance.

    You might consider doing this a different way - one would be to allow your flow to accept multiple emails (through a single argument) and return the results of that.

    The other would be to iterate on the SelecteItems and get the results of each one.

    Ex.

    Set(RequiredUser,
     ForAll(
     DataCardValue176.SelectedItems,
     {FullName: DisplayName,
     EmpID: GetEmployeeId.Run(DataCardValue176.Selected.Mail).employeeid
     }
     )
    )

    This will result in a RequiredUser variable with a Table of records with the FullName and EmpID as selected from the Combobox and returned from your flow.

     

    I hope this is helpful for you.

  • indhaa Profile Picture
    on at

    Hi Randy,

     

    Need your wisdom on this. I haven't tried above yet but i think it will work on a New Form Mode. But I think my approach is still wrong.

     

    So I'm just updating this data to Multi line of Text Column on my SP List. So in Edit Form Mode i need to make sure these users are selected automatically in the combobox. So i need to get the email address so I can compare and have them selected in the combobox in edit mode by default. Is that possible?  Hope I'm making sense to you.

     

    I'm using Multi line of text instead of People or Group on SP List because i don't want the data of the users to change later on the form (for example due to department or title change). Previously in my other form the requirement is to select one user, so i was able to do this but this is something new.

     

    Can help on this? 

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @indhaa 

    Yes, you can easily convert multi-line text strings into combobox items.  They need to be stored with some separator in them such as a semicolon or other.  Then they just need to be "broken apart" in the Default Selected Items property of the Combobox.

     

    Perfectly understand saving the names in text rather than a Person column due to people no longer there.  We do this often.  

     

    So tell me more about where you are on the process and I'd be happy to jump in an suggest things you need.

  • indhaa Profile Picture
    on at

    So based on what you said I think i will do like this. 

     I added a combox to the Datacard and added your code on the OnChange Property

     

    Set(RequiredUser,
    ForAll(
    ComboBox1.SelectedItems,
    {FullName: DisplayName,
    EmpID: GetEmployeeId.Run(ComboBox1.Selected.Mail).employeeid
    }))

     

    So in the DataCardValue176 default property i will refer to 'RequiredUser'. How do you set this, I'm unable to do it. it is not accepting my code,

     

    So next I will create another column on my SP List to store the selected emails and then have a Lookup field to select the items in the combobos. No idea how to achieve this. So maybe in the Edit Form mode, OnVisible of the screen i can say to lookup and select the items. Is that possible. Actually I don't know how to do this and need more of your help to do this.

     

    Can help?

     

      

     

     

     

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @indhaa 

    Well, actually, you're trying to set the Default property of the Combobox...it does nothing.  You need to set the DefaultSelectedItems property (DSI) to select items in the combobox.

    Also, I would actually never use the OnChange action of a combobox for this.  And especially not like that as it will kill performance.

     

    The problem that I see is that your going to potentially have some problems with the Items property matching to the DSI.  What is your Items property on the Combobox?

     

  • indhaa Profile Picture
    on at

    Hi,

     

    This is the item property of my Combo Box.

    Filter(
    Office365Users.SearchUser({searchTerm:ComboBox1.SearchText}),
    !IsBlank(JobTitle) && !IsBlank(Mail) && !IsBlank(Department))

     

    Previously also I used the OnChange Property of the combo box. Can't find any degradation. I think it is the only way, otherwise i have to hide the datacard which shows the (employeeID and full name) and put that code during form submit.

     

    I have a combobox and a Text Input one now. So want to update Text Input with the changes (Want to add RequiredUsers as the default of this) and during Edit FormMode want to select the items in the text Input with the Combo Box. Hope I'm making it clear. I deleted and added the field again and added a Combox in addition to the existing datacard.

    indhaa_0-1620283751528.png

     

     

     

     

  • indhaa Profile Picture
    on at

    Hi,

     

    I would be able to do this with a Gallery, using InfoPath Repeating table concept and having another SP lIst storing these data. But the issue is i'm using Phone Format , so the space is less and I don't want user to scroll. I already have a Gallery of this in the form with this concept.

     

    So If I can get the SelectedItems to the datacard and use this means I need only a TextInput or a label to achieve this feat. But I don't know how to do that. If you have an idea, pls let me know

  • indhaa Profile Picture
    on at

    Any thought?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard