PowerApps Limit the People to select from Azure AD Group

Requirement

We had a requirement recently to filter the list of users in PowerApps from the Azure AD group.  The client has a specific group called “Executive Sponsors” that only list should show in the list of users/person to select in PowerApps. And PowerApps uses Sharepoint as a data source.

Challenge

Person record in Sharepoint is different from Azure AD User. Both Schema and structure are different. We can’t directly use it.

Solution

To display the ComboBox, we need Azure AD Connector, and the Azure AD user needs to be converted to a SharePoint Person record when we save the data.

 Azure AD Group SetUp

  • Go to Azure AD
  • Create a Group
  • Select Microsoft 365 as Group Type
  • Enter Name and Other basic Information
  • Add members to the group


PowerApps Setup

  • Have a gallery
  • Have an Edit form
    • Person Combo box added
    • DataSource to SharePoint List
    • Item property to Gallery Selected

 

Setup to use Azure AD group

We need to have two connectors to access the Azure AD group and User Details

  1. Office365Groups
  2. Office365Users

Set the Items property of the person combo box to

Office365Groups.ListGroupMembers(“AZURE AD GROUP GUID”).value

Set the DefaultSelectedItems of the person combo box to

If(
!IsBlank(ThisItem.’Exec Sponsor’.Email),
Office365Users.UserProfileV2(ThisItem.’Exec Sponsor’.Email),
Blank()
)

Set the Update property of the person Data Card to

If(
!IsBlank(ExecSponsorDataCardValue.Selected.mail),
{
Claims: “i:0#.f|membership|” & Lower(ExecSponsorDataCardValue.Selected.mail),
Department: “”,
DisplayName: Lower(ExecSponsorDataCardValue.Selected.displayName),
Email: Lower(ExecSponsorDataCardValue.Selected.mail),
JobTitle: “”,
Picture: “”
},
Blank()
)

 

Important: At the time of writing this blog post, to set a Blank value for the person field, we need to enable some settings

  • Go to Settings
  • Select “Upcoming features”
  • Click the “Experimental” tab
  • Enable “Formula-level error management”

StalinPonnusamy_0-1634734721279.png

Result/Output

Person Combo box shows only the users from Azure AD and is able to save successfully to SharePoint by converting Azure AD User/Object to SharePoint Person Record.

Record Saved Successfully in Sharepoint

Leave a Reply

Your email address will not be published.