Populate Power Apps drop down box with Office 365 group

A friend put forth an interesting, and probably common, scenario. He created a simple app in Power Apps. The app was mostly a basic form with text input fields and one drop down field. The drop down was populated by a SharePoint list with team member names in the list. The app worked and everything looked good but my friend explained that the SharePoint list required manual updates. When a new team member started and when a team member departed, someone needed to manually update the SharePoint list. Since no one wanted to be responsible for doing that, list upkeep was not sustained and the list had become very outdated.

My friend decided to resolve the issue by using an existing Office 365 group, one that is dynamically updated when users join and depart the organization, to populate the drop down. Unfortunately, he was having trouble getting this idea to work. He tried populating the drop down Items property with the group information but it didn’t work.

I gave my friend these steps to get the drop down working and thought that others might need some help overcoming this challenge, too.

I hope these steps help you work with drop down boxes in Power Apps!

Populate Power Apps drop down with Office 365 group

Connect to Office 365 groups in your Power Apps

  1. In the canvas app, click the data icon, in the left pane.
  2. Next, click Add data.
  3. In the Search box, type office 365 groups.
  4. Select Office 365 Groups from the search results list.
  5. Click the Connect button.

  6. If you haven’t already, add a drop down box to your screen.

Create a collection in Power Apps

  1. As shown in the image below, select Tree view.
  2. Next, select App.
  3. Then select OnStart in the properties box because we want the collection to get created when the app loads.

  4. In the formula bar type or paste the following code:

    ClearCollect(myCollection,{displayName:""}); Collect(myCollection,Office365Groups.ListGroupMembers("xxxxxx").value)

    Replace myCollection with the desired name of your new collection. Remember to name the collection something relevant and understandable.

    Replace xxxxxx with the object ID of group. You can find this is in Azure Active Directory by searching for the group and viewing the Overview blade.

    Note: In my example, I begin with ClearCollect(myCollection,{displayName:””}); because I wanted to have a blank entry at the top of my collection. If you don’t want or need this in your list, refrain from adding that line of code.

Run OnStart and view the collection

  1. In Tree view, click App.
  2. Next, click the ellipsis.
  3. Then click Run OnStart. This runs any commands in the OnStart property and mimics what happens when the app is loaded.

View the collection

  1. Click the View menu.
  2. Click Collections.
  3. You should recognize names in your collection.
  4. Go back to the canvas.

Apply the collection to the drop down box

  1. On the canvas, click the drop down box you previously created.
  2. In the properties pane, click the Items property drop down arrow.
  3. Select your collection. (The value field should populate automatically.)

That’s it! You’re done! Enjoy your drop down box populated with the members of an O365 group!