I was writing my first callout ( plugin) for CRM 4.0 when i recieved this error.
I realized that this was because of this line of code in my plugin
public void Execute(IPluginExecutionContext context)
{
DynamicEntity entity = (DynamicEntity)context.InputParameters.Properties[“Target”];
……
For Create and Update message there was no problem.
Problem started coming when i registered the step for Assign message.
So modified the code as following
DynamicEntity entity = null;
if (context.InputParameters.Properties.Contains(“Target”) &&
context.InputParameters.Properties[“Target”] is DynamicEntity)
{
// Obtain the target business entity from the input parmameters.
entity = (DynamicEntity)context.InputParameters.Properties[“Target”];
}
For Assign Message used the following line of code
if (context.MessageName == “Assign”)
{
Moniker myMoniker = null;
if (context.InputParameters.Properties.Contains(“Target”) &&
context.InputParameters.Properties[“Target”] is Moniker)
{
// Obtain the target business entity from the input parmameters.
myMoniker = (Moniker)context.InputParameters.Properties[“Target”];
}
myMoniker.Name –> Gave the name of the entity
myMoniker.Id –> Gave the id of the entity
Bye
Discover more from Nishant Rana's Weblog
Subscribe to get the latest posts sent to your email.

That was cool.
LikeLike
Hi Nishanth,
One doubt i have registered my plugin in Setstate Event. I have used following lines of code to get the context..
“if (context.InputParameters.Properties.Contains(“EntityMoniker”) &&
context.InputParameters.Properties[“EntityMoniker”] is Moniker)
{
entitymonik = (Moniker)context.InputParameters.Properties[“Target”];”
– From this context i need to get one lookup attribute.
how to get that.. please help me.
LikeLike