The Organization hierarchy in Office 365 is based on the Manager attribute of users, and can be shown in Delve for example. But the Manager attribute is not synced to Dynamics 365 when users are enabled.
We can get the manager of a user by calling the Get manager (V2) action of the Office 365 Users connector in Flow. Since the Manager field of the User entity in Dynamics 365 is a lookup (to the User entity) we need to get the userid of the manager.
There’s an update version of the flow, see: Get & set manager of CDS|D365 users with Power Automate flow
Here is the overview of the flow:
First we get all active users and for each user we get their details and get their manager.
We check if the manager is not empty, and get the user record filtered on the user name of the manager.
Then we get the details of the manager’s user record, if available (I didn’t build in this check yet).
Finally we update the user record with the userid of the manager in case they’re not equal.
And here are the (test) results in Dynamics 365:
The Organization hierarchy is now available in Dynamics 365 as well.
Disclaimer: when the manager is not part of the business unit hierarchy then the flow will presumably fail, so be sure to administer the business unit hierarchy in Dynamics 365 in case of organizational changes that have impact on the security structure.
Great article on the first Action, what identifier are you using for the user identifier?
Hi Terry,
It’s the List (User) records action with a filter query. See other post for details:
https://2die4it.com/2018/09/22/user-attribute-values-lost-in-synchronization-flow-to-the-rescue-department/
Hope it helps.
Hello,
I’m assuming this will fail if the manager is not also a user in Dynamics 365… please correct me if I’m wrong.
thanks!
Hi Kaitlin,
Yes, if there’s no user found with the userprincipalename of the manager, the flow will stop because there’s no “each to apply” to.
is this solution still valid ?
we dont’ observe user related flows for Dynamics.
Dynamics is showing deprecated
Hi appadala,
I’ve written a new blog post with an update of the solution to get & set the manager of CDS users.