Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM forum
Suggested answer

how to get user email from plugin and update its

Posted on by Microsoft Employee

ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
//get the execution context from the service provider
IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
//obtain the org service ref to make web service calls
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);

try
{
Entity target = (Entity)context.InputParameters["target"];
Entity objUser = service.Retrieve("systemuserid", userGuid, new ColumnSet("primaryemailaddress", "systemuserid"));

if (objUser != null && objUser.Contains("primaryemailaddress") && objUser["primaryemailaddress"] != null)
{
string Useremail = (string)objUser["primaryemailaddress"];
}

}
catch (Exception ex)
{
throw (ex);
}
}

  • Suggested answer
    ankit_singhal Profile Picture
    ankit_singhal 560 on at
    RE: how to get user email from plugin and update its

    Then you need to first get the guid of user lookup then based on that guid you can get the email address from user record.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: how to get user email from plugin and update its

    Yes

  • ankit_singhal Profile Picture
    ankit_singhal 560 on at
    RE: how to get user email from plugin and update its

    is there any lookup of that user on account record?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: how to get user email from plugin and update its

    account

  • ankit_singhal Profile Picture
    ankit_singhal 560 on at
    RE: how to get user email from plugin and update its

    Please explain your requirement. On which entity your plugin is trigger? you can use fetch xml as well to get your email in plugin

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: how to get user email from plugin and update its

    Hi i need help on this

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,696 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,490 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans