public void Execute(IServiceProvider serviceProvider)
{
IPluginExecutionContext context = (IPluginExecutionContext )serviceProvider .GetService (typeof (IPluginExecutionContext ));
if (context .InputParameters .Contains ("Target") && context .InputParameters ["Target"] is Entity )
{
Entity entity = (Entity )context .InputParameters["Target"];
if(entity.LogicalName =="account")
{
if (entity.Attributes .Contains ("accountnumber") == false )
{
Random rndgen = new Random ();
entity .Attributes .Add ("accountnumber",rndgen .Next ().ToString ());
}
else
{
throw new InvalidPluginExecutionException ("the account number only set by the system.");
}
}
}
}
}
}
In this Code their and registration also succedded
but in crm form it can't working why ?
thank u
Naveen