Today, I have written a plug-in which fires on record delete message.
I have deployed it successfully and when I test it, the code is not firing and
even I don't see any error message. I went further and debugged the code and
found the cause of the issue.
Event
|
Type
|
|
Delete
|
context.InputParameters["Target"]
|
EntityReference
|
Create
|
context.InputParameters["Target"]
|
Entity
|
Update
|
context.InputParameters["Target"]
|
Entity
|
So your code should be as follows
Delete
if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is EntityReference)
{
if (context.MessageName
== "Delete")
{
// Your code
}
}
Create and Update
if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
{
if (context.MessageName
== "Create")
{
// Your code
}
if (context.MessageName
== "Update")
{
// Your code
}
}
--
Happy CRM'ing
Gopinath
No comments:
Post a Comment