cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dhofknecht
Frequent Visitor

ComboBox DefaultSelectedItems w/ Office 365 Users Connector

I am looking to setup a combobox for of users with the Office 365 Users connector and while I was able to properly populate the combobox, I am having trouble setting up the DefaultSelectedItems property for the combobox on my edit form.  The PowerApp pulls the majority of the data from a SQL Server where i have a User field in my table (we will call it Table1 for the sake of the example). So for example if on the Detail Screen the txtUser = "Mike" then when selecting to edit the record, I want the DefaultSelectedItem for the comboboxUser to already have "Mike" selected.  I have tried several methods from LookUp to context variable and have not had much luck.  Has anyone been able to setup the DefaultSelectedItems for Office 365 Users and if so how did you structure your formula to select the User from Office 365 Users that is stored in the SQL database.

6 REPLIES 6
dhofknecht
Frequent Visitor

After some more testing I found that this worked for me:

Office365Users.SearchUser({searchTerm:txtUser})

Great - I had the same problem and your solution solved it. One question though - hopefully someone can answer:

 

if you want to select several items as default...?  In my NewForm I've selected 3 users and updated that to my datasource (excel) using Concat(ComboBox_user.SelectedItems;DisplayName;";"). 

Your formula (in my version Office365users.SearchUser({searchTerm:DataCardValue2}) - only preselects correctly when datacardvalue2 contains single user, not when it contains multiple users (user1;user2;user3).

Any Idea @dhofknecht how to make default select user1 and user2 and user 3?

 

Cheers,  Preben

Hello @dhofknecht ,

 

You should be able to use a forall to find the relevant items in the array.
ForAll(
["value1","value2"],
First(Office365Users.SearchUserV2({searchTerm: Value,top:1}).value)
)

 

Let me know if you don't come right.

Hi, @DavesTechTips 

 

I know this thread is old, but I'm having trouble getting your formula to work correctly. In my table, I have five email addresses, which I want to be the default selected items in my combo box, with the combo box showing their names. However, when I use your formula, only the first person in the table is returned. If I remove the First() and top:1 bits, then "[object Object]" is returned.

 

Here's what I have in ComboBox1.DefaultSelectedItems now. It's returning "[object Object]."

 

ForAll(
    ItemDetail.Contacts, //This table contains 0–10 email addresses.
    Office365Users.SearchUserV2({searchTerm: Value}).value.DisplayName
)

 

 

What am I doing wrong here?

 

Edit: My bad. The formula I used works. My problem was that I had ComboBox1.SelectMultiple set to false. Once I set it to true, it worked fine. Dumb oversight on my part.

AkankshaGupta
Frequent Visitor

Hi @AIUYM19 ,I tried same approach to display selected users but getting [object obejct] issue even though select multiple is checked .However i'm getting [Object Object] 3 times if there are 3 usernames expected in default .

I'm using this combo box in a form and in view mode it should show selected users which was saved in 'UserTable' in newform/editform mode .

 

 

ForAll(Filter(UserTable,ThisItem.ID=CurrentIDOnForm),
    Office365Users.SearchUserV2({searchTerm:ThisRecord.UserEmail}).value.Mail)

 

 

Hi, @AkankshaGupta. I almost never use PowerApps controls in "view" mode (I assume you mean DisplayMode.View in the DisplayMode property), because it tends to do strange, strange things to the parameter behaviours. If I need to prevent a user from clicking something, I typically cover it with a transparent rectangle with the OnSelect property equal to false.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

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