CRM 2011: How to find out the origin of a trigger for a plugin?
I need to find out with code in a plugin for Microsoft Dynamics CRM 2011 what was the origin of the trigger that fires the current plugin.
Example: I have a plugin that fires on the update message of a contact. I also have another plugin that fires on the update of a custom entity. In these second plugin, i also do an update of the contact entity. So here i need to know i the contact plugin fires because of a change on the form or because an other plugin called a contact开发者_StackOverflow社区 update.
I read about callerorigin for crm 4.0. But that doesn't exist anymore for crm 2011.
Thanks!
Could you not check IPluginExecutionContext's Depth
property? If called from another plugin if will be 2 (or greater...)
I don't think there is a generic way to determine the origin like you want, but a simple solution would be to add a bit field called "UpdatedFromPlugin" to Contact and set that to true when you update the contact from another plugin. Then in the contact plugin, check that flag.
精彩评论