Identifying when a Dynamics Plugin Fires

I recently had a problem where we had multiple events tied to a single plugin (not the perfect architecture, but one I had to work with) on the disassociation of a record from a Many-2-Many grid.

pluginevents.png

The problem with the above implementation is that for each Disassociation even we were registered for both the Pre and Post events (whereas one plugin required both, but another only required the Post event).

To detect which even the plugin was handling I was able to key off the following Input Parameter to what event was firing.

localContext.PluginExecutionContext.InputParameters.Contains("parentExecutionId")

If the “parentExecutionId” variable existed, I was in the Pre-Step and if it did not I was in the Post-Step.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s