Thursday, September 23, 2010
Getting userId and Information
How to get preOwner and postOwner in Plugin
SecurityPrincipal assignee = (SecurityPrincipal)context.InputParameters.Properties["Assignee"];
Guid guidNewOwner = assignee.PrincipalId;
Moniker moniker = (Moniker)context.InputParameters.Properties["Target"];
Guid id = moniker.Id;
//pass this id and get owner id from lead
ICrmService service = context.CreateCrmService(true);
Guid guidOldOwner = GetOwner(id.ToString(), service);
How to fire a Workflow through Plugin
ExecuteWorkflowRequest request = new ExecuteWorkflowRequest();
//Assign the ID of the workflow you want to execute to the request.
request.WorkflowId = new Guid("stringWorkFlowid");
//Assign the ID of the entity to execute the workflow on to the request.
request.EntityId = id;
// Execute the workflow.
ExecuteWorkflowResponse response = (ExecuteWorkflowResponse)service.Execute(request);