Search code examples
azure-active-directorypowerapps

Show members of AD group in Power Apps gallery items


I am working on an app that  fetches Azure AD groups based on amount value and stores the names of the groups in SharePoint column (Person/Group type).

In the Gallery, I have multiple rows in the following format.

enter image description here

The AD Groups in the gallery are fetched from SP column (person/group type) using the code:

ThisItem.ADGroup1.DisplayName 

ThisItem.ADGroup2.DisplayName

In the gallery items, is it possible that I can show the members of each group? For example, there are 3 users in UserGroup1, so I want to show the members of that group (emails of group members or display names)

So the gallery view can be 

enter image description here

Thanks in advance


Solution

  • it is definitely possible, but the right implementation depends on what you want to do with the names.

    See, the group members are a sub-table in your gallery item, so you could either:

    1. Nest another gallery and display the group members there
    2. Use an HTML Text control and the Concat() function to display members, for example as links to send them emails: Concat('AD Group 1'.value,"<a href='mailto:" & email & "'>" & displayName & "</a>", "; ")

    Galleries have more functionality, HTML Text is perhaps easier.

    To merely show the member names:

    Concat('AD Group 1'.value,displayName, "; ")

    To iterate the members and send individual emails:

    ForAll('AD Group 1'.value,Office365Outlook.SendEmailV2(email,"(subject)","(body)")