Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

get user's manager in plugin

Posted on by 1,558

Hello All,

I need to send email to initiating users's manager via plugin C# code.

Can anyone help suggest me how i can get user's manager via code in plugin.

*This post is locked for comments

  • Suggested answer
    Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: get user's manager in plugin

    You can use the following code:

           private Guid RetrieveUserManager(Guid userId)

           {

               ColumnSet columnset = new ColumnSet("systemuserid", "parentsystemuserid");

               Entity user = service.Retrieve("systemuser", userId, columnset);

               Guid parentSystemUserId = user.Contains("parentsystemuserid") ? ((EntityReference)(user["parentsystemuserid"])).Id : Guid.Empty;

               return parentSystemUserId;

           }

  • Suggested answer
    SergiiChvyr Profile Picture
    SergiiChvyr on at
    RE: get user's manager in plugin

    Hi,

    Inside plugin you can get initiating user and Organization Service. Using it , retrieve manager details from corresonding SystemUser record

    To send email refer

    community.dynamics.com/.../149773

  • sdnd2000 Profile Picture
    sdnd2000 2,397 on at
    RE: get user's manager in plugin

    you need use fetchxml or linq to query based on the user id.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans