on Creation of User, i need to write a plugin to create a contact with that user full name
may i know how to do this in MS CRM 2013?
thanks in advance....
Please find below code:
public void Execute(IServiceProvider sericeProvider)
{
IPluginExecutionContext context = (IPluginExecutionContext)sericeProvider.GetService(typeof(IPluginExecutionContext));
IOrganizationServiceFactory factory = (IOrganizationServiceFactory)sericeProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = factory.CreateOrganizationService(context.UserId);
if (context.InputParameters["Target"] is Entity && context.InputParameters.Contains("Target"))
{
Entity User = context.InputParameters["Target"] as Entity;
string Username = User["fullname"].ToString();
Entity contact = new Entity("contact");
contact["lastname"] = Username;
service.Create(contact);
}
}
i Resisted this plugin in MS CRM by using plugin registration tool( message : CREATE ;Primary entity:Systemuser;on Post operation ) but it is not working for me ...