Our today’s tipster is the man himself: Tanguy “The XRM Toolbox” Touzard.
Did you ever feel lost when you wanted to develop a plugin and didn’t know what keys to use in IPluginExecutionContext.InputParameters or IPluginExecutionContext.OutputParameters? Did you ever wonder why we do use the mysterious “Target” key when writing a plugin for Create, Update or Delete messages? No more!
When writing your plugin class for a specific message, just find the corresponding Request/Response pair and browse the properties of the Request part for InputParameters and Response part for OutputParameters. You can use these object in your code to enumerate all the keys and then remove this snippets right after you found the keys and their types.
For example, if I’m a new developer and want to create a plugin on Create message but don’t know what keys to use, here is the sample code I can write to find these values (note that only properties that are bold on intellisense menu are available for use)
As you can see, you can even check the type of the parameter to cast it correctly, so your code might end up looking like the following:
Great tip. Really helpful especially in deciding whether the data type of Target is Entity or EntityReference. This will save my time to check the SDK or MSDN doco 🙂