I build a plugin that runs in account update message that makes some validation not to duplicate the record. But if I try to disable that account or merge with another one it triggers the plugin.
How can I tell if the plugin was triggered by an activate/deactivate/merge action, or event mode like the one in CRM Dynamics 2011 Save Event Arguments Reference?
To add to Pete Oakey’s answer, you can actually tell your plugin to fire only when certain fields are changed at the registration phase, in addition to testing this in actual code @ runtime, by changing the “Filtering Attributes” of the plugin step. So unless your validation logic specifically needs the
StateCode/StatusCodeattributes to correctly process, you can filter those two attributes out, or just include the attributes your validation logic needs.Original answer:I believe you can reference the
IExecutionContext.Depth Propertyof theIPluginExecutionContextobject.So you can use an if statement to check if
Depth > 1.