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 / Filtering Office365Use...
Power Apps
Answered

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

(0) ShareShare
ReportReport
Posted on by 753

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?

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

    @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 Profile Picture
    753 on at

    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.

  • Community Power Platform Member Profile Picture
    on at

    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

  • Al_10 Profile Picture
    1,691 Super User 2024 Season 1 on at

    @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))

     

  • Greg27 Profile Picture
    753 on at

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

  • Greg27 Profile Picture
    753 on at

    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?

  • Al_10 Profile Picture
    1,691 Super User 2024 Season 1 on at

    @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 Profile Picture
    753 on at

    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?

  • indhaa Profile Picture
    on at

    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.

  • Al_10 Profile Picture
    1,691 Super User 2024 Season 1 on at

    @Greg27 

    yes default is 100 for Office365Groups.ListGroupMembers(). you can increase that limit up to 999

     

    button.OnSelect = 

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

     

    combobox.Items = 

    Sort(colAzureGr, displayName) 

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 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard