web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

how to get user email from plugin and update its

(0) ShareShare
ReportReport
Posted on by

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);
}
}

I have the same question (0)
  • Community Member Profile Picture
    on at

    Hi i need help on this

  • ankit_singhal Profile Picture
    560 on at

    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
    on at

    account

  • ankit_singhal Profile Picture
    560 on at

    is there any lookup of that user on account record?

  • Community Member Profile Picture
    on at

    Yes

  • Suggested answer
    ankit_singhal Profile Picture
    560 on at

    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.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 74 Super User 2025 Season 2

#2
Daniyal Khaleel Profile Picture

Daniyal Khaleel 32 Most Valuable Professional

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 31 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans