Get target entity name in ‘SetState’ plugin

Plugin Development tips for MS CRM 2013:

You will get the target entity’s logical name with following code

if (context.InputParameters.Contains(“Target”) && context.InputParameters[“Target”] is Entity)

In SetState Plugin don’t provide a InputParameter called Target as Create or Update message.But it provides another object called EntityMoniker having EntityReference as Type not Entity.

if (context.InputParameters.Contains(“EntityMoniker”) && context.InputParameters[“EntityMoniker”] is EntityReference)
// Obtain the target entity
EntityReference entityMoniker = (EntityReference )_context.InputParameters[“EntityMoniker”];
string entityLogicalName = entityMoniker.LogicalName;


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s