1
votes

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 update.

I read about callerorigin for crm 4.0. But that doesn't exist anymore for crm 2011.

Thanks!

2

2 Answers

5
votes

Could you not check IPluginExecutionContext's Depth property? If called from another plugin if will be 2 (or greater...)

2
votes

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.