Monday, November 12, 2012

How to get entity instance id in CRM 4.0 plugin for each message type

this post you can get instance id in CRM:

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;


reference : http://rami-heleg.blogspot.com/2009/12/how-to-go-get-entity-instance-id-in-crm.html

No comments:

Post a Comment