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

Filtering Office365Users in a ComboBox to show users, not Service Accounts

We setup a ComboBox to show all users in Office365Users, but it includes Service Accounts. Is there a way to filter out Service Accounts? I was thinking maybe displaying only those who belonged to at least 1 of 3 AD Security Groups, but we are not seeing how to use a Security Groups. Is that possible or is there another field that might work?

2 ACCEPTED SOLUTIONS

Accepted Solutions
Alex_10
Super User
Super User

@Greg27 

you can place this code in App.Onstart to avoid using a button.

App.Onstart = ClearCollect(colAzureGr, Office365Groups.ListGroupMembers("YourSecurityGroupGUID", {'$top': 999} ).value);

 

This: Sort(colAzureGr, displayName)  should sort accounts in the combobox by display names in asc order.

It does not do that?

View solution in original post

Alex_10
Super User
Super User

@Greg27 

Sort(ColAzureGr, surname)

 

if you are sure that each name appear only once in that group, try to change in the right settings panel:

 

combobox.Fields->Edit->Layout->Single

View solution in original post

21 REPLIES 21
Alex_10
Super User
Super User

@Greg27 

i would add a fake Department for all service accounts in Azure, e.g "service".

 

comboBox.Items = 

Filter(Office365Users.SearchUser(), Not(Department = "service"))

Greg27
Helper III
Helper III

So, there is no way to do it with AD Security Groups? I would rather not do that extra work of adding the Departments if possible. There are a ton of Service Accounts.

Karldajabron
Helper I
Helper I

Are there any defining names for the service accounts? Ie: accounting_BOT@email.com.

 

If so, you could filter based on if the email contains "BOT" or something of the sorts

Alex_10
Super User
Super User

@Greg27 

 

need to get group members first using Office365Groups connector:

button.OnSelect = 

ClearCollect(colAzureGr, Office365Groups.ListGroupMembers("YourSecurityGroupGUID").value);

 

ComboBox.Items = 

Filter(Office365Users.SearchUser(), Not(DisplayName in colAzureGr.displayName))

 

I am not seeing any defining names for the service accounts.

Greg27
Helper III
Helper III

If I use the Office365Groups connector with my ComboBox, I am no longer allowed to type anything into the box and I am seeing accounts that are not a member of the group. I noticed that your ComboBox.Items command used Not(DisplayName in ColAzureGr... If ColAzureGr is holding all accounts that I would want to display, wouldn't just simply displaying what is in it be what I want?

Alex_10
Super User
Super User

@Greg27 

the group members in the code meant to be service accounts that should be excluded from the combobox.

i assume your combobox does not allow multiple selection.

when you make any changes, you need to make sure that toggle 'Allow searching' is ON on the right settings panel ( as it gets off sometimes as code changes).

 

or

yes, you can place all combobox accounts into a single azure group, get group members into a collection in powerapps and point combobox items (source) to that collection to avoid expensive http calls.

 

// get accounts for combobox

button.OnSelect = 

ClearCollect(colAzureGr, Office365Groups.ListGroupMembers("YourSecurityGroupGUID").value);

 

ComboBox.Items = colAzureGr

 

 

Greg27
Helper III
Helper III

Ah, the "Allow searching" slider was off.

 

I am now seeing users in the ComboBox, but it is only listing 100 records and not in alphabetical order. I should be able to figure the sorting out, but I haven't seen anything limiting the results to 100. Is this a default that I need to override?

Hi

 

Wouldn't the user be searching the name instead of scrolling. Also regarding the service account, check if the department or title is empty for those accounts. If so you can filter to produce only users with not empty title field. That's what I have done and its works for me.

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

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

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