Display Employee ID in PowerApps from Azure AD

This blog describes displaying Employee ID from Azure AD in PowerApps. PowerApps doesn’t have any connector to get some information from Azure AD. As a workaround, we have to use Graph API and Power Automate to get Employee ID.

Requirement

Our goal is to display Employee ID from Azure AD in PowerApps

Azure AD (With Employee ID Property)

First will use Microsoft Graph explorer to play around to find the API. Here are the details for the Graph API.

Microsoft Graph Explorer

URL : https://developer.microsoft.com/en-us/graph/graph-explorer

The below query to get employee id for the given user or employee

https://graph.microsoft.com/v1.0/users/{User Email Id}?$select=employeeid

Sample

https://graph.microsoft.com/v1.0/users/stalin@ltiblogs.onmicrosoft.com?$select=employeeid

Sample to use Graph explorer

We can’t call Microsoft Graph API directly from PowerApps, so we have to use Power Automate. It will two-step process.

Solution

  1. Power Automate with Graph API
  2. PowerApps

Data Flow

PowerApps –> Power Automate –> Microsoft Graph –> Power Automate –> PowerApps

1. Power Automate

  • Create Instant cloud Flow
  • Select Trigger: PowerApps
  • Name: Get Employee ID

Overall Flow Steps/Actions

Step by steps Details

Initialize User Email – Ask in PowerApps

HTTP Call

URI –> https://graph.microsoft.com/v1.0/users/@{variables(‘Current User Email’)}?$select=employeeid

Note: Make sure to Add Authentication

Parse JSON

For Parse JSON Step on the flow, Click “Generate from the sample,” paste the below sample code.

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users(employeeId)/$entity",
    "employeeId": "sp0108"
}

StalinPonnusamy_4-1636553882876.png

Respond to a PowerApp or flow

2. PowerApps

Set OnStart property of App to

Set(UserInfo, User())

Add the Power Automate (GetEmployeeID) as Data Source

Set OnVisible property of the screen to

Set(VarEmployeeId,GetEmployeeID.Run(UserInfo.Email).employeeid)

Set the text property of the label to

VarEmployeeId

Result/Outcome in PowerApps

Conclusion

Using Power Automate and Microsoft Graph, we can get Employee ID from Azure AD to PowerApps.

2 comments

Leave a Reply

Your email address will not be published.