I discovered that in some of my code I have the following syntax guarding the plugin from FUBARing. I can't for the love of god not remember why I put the disjuction conditional for EntityReference.
Is Context.InputParameters["Target"] every EntityReference?
bool goodToGo
= Context.InputParameters.Contains("Target")
&& Context.PrimaryEntityName == "email";
&& (
Context.InputParameters["Target"] is Entity
|| Context.InputParameters["Target"] is EntityReference);
Is it ever anything other than Entity?
Target can be also an EntityReference, from MSDN:
Note that not all requests contain a Target property that is of type Entity, so you do have to look at each individual request or response. For example, DeleteRequest does have a Target property but its type is EntityReference.
Understand the Data Context Passed to a Plug-In
So depending on the logic of your plugin you may need to check the property type also for EntityReference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With