Delete event -> Type of context.InputParameters["Target"] is EntityReference
Create event / Update event ->Type of context.InputParameters["Target"] is Entity
In a nutshell,
context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
if (context.InputParameters.Contains("Target") &&
{
if (context.MessageName == "Delete")
{
}
}
Whereas Create / Update events work as follows
context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
if (context.InputParameters.Contains("Target") &&
{
if (context.MessageName == "Create")
{
//Code to be executed during Create event of an entity
}
if (context.MessageName == "Update”)
{
//Code to be executed during Update event of an entity
}
}
Please note the key difference Entity and EntityReference
No comments:
Post a Comment