Wednesday, March 17, 2010

To get instance id for each type of event in plugin for crm 4.0

Massage name “Create”:

Guid instanceID = new Guid(context.OutputParameters.Properties["id"].ToString());

Massage name “Update”:
Guid instanceID = (Guid)((Microsoft.Crm.Sdk.Key)((Microsoft.Crm.Sdk.DynamicEntity)context.InputParameters.Properties["Target"]).Properties[context.PrimaryEntityName + "id"]).Value;

Massage name “SetState”:
Guid instanceID = new Guid(context.OutputParameters.Properties["id"].ToString());

Massage name “Assign”:
Guid instanceID = vInstanceID = (Guid)((Microsoft.Crm.Sdk.Moniker)context.InputParameters.Properties["Target"]).Id;

Massage name “Delete”:
instanceID = ((Microsoft.Crm.Sdk.Moniker)context.InputParameters.Properties["Target"]).Id;

Massage name “Close”:
Guid instanceID = ((Microsoft.Crm.Sdk.Lookup)((Microsoft.Crm.Sdk.DynamicEntity)context.InputParameters.Properties["IncidentResolution"]).Properties[context.PrimaryEntityName + "id"]).Value;

Massage name “Route”:
Guid instanceID = ((Microsoft.Crm.Sdk.Moniker)context.InputParameters.Properties["Target"]).Id;

Massage name “SetStateDynamicEntity”:
Guid instanceID = ((Microsoft.Crm.Sdk.Moniker)context.InputParameters.Properties["EntityMoniker"]).Id;

No comments: