I have deployed successfully into Dynammics CRM online version. when the records were added the plugin was not running.
Postimage plugin,
Update method
Lead Entity
Below This is my code
public class PostOperationleadUpdate: IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
IPluginExecutionContext context = (IPluginExecutionContext)
serviceProvider.GetService(typeof(IPluginExecutionContext));
if (context.PostEntityImages.Contains("Target"))
{
Entity postMessageImage = (Entity)context.PostEntityImages["Target"];
if (postMessageImage.Attributes.Contains("parentcontactid") == true)
{
ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
EntityReference customer = postMessageImage.GetAttributeValue<EntityReference>("parentcontactid");
Entity contact = service.Retrieve(customer.LogicalName, customer.Id, new ColumnSet(true));
contact.Attributes["firstname"] = postMessageImage.GetAttributeValue<string>("firstname"); //String Field
service.Update(postMessageImage);
}
}
}
}
}
*This post is locked for comments