CRM 2011 – IExecutionContext and the useful variables you can access

Whilst studying for the Extending CRM 2011 exam, I have been looking at the IExecutionContext and it has some interesting properties you can access in the plugins.

Firstly you have

IExecutionContext Interface

This is a base interface that defines the contextual information passed to a plug-in or custom workflow activity at run-time.    The properties of this base class are populated by the event execution pipeline before the plugin or custom workflow code is run.

To see the various properties, I found this useful page, which I have copied below.   I have probably used most of these variables at one time or another, depth to see how many times the plugin has run is one of the most useful.

IExecutionContext Properties

This topic has not yet been rated – Rate this topic
[Applies to: Microsoft Dynamics CRM 2011] Public Properties


Name Description
public property BusinessUnitId Gets the global unique identifier of the business unit that the user making the request, also known as the calling user, belongs to.
public property CorrelationId Gets the global unique identifier for tracking plug-in or custom workflow activity execution.
public property Depth Gets the current depth of execution in the call stack.
public property InitiatingUserId Gets the global unique identifier of the system user account under which the current pipeline is executing.
public property InputParameters Gets the parameters of the request message that triggered the event that caused the plug-in to execute.
public property IsExecutingOffline Gets a value indicating if the plug-in is executing from the Microsoft Dynamics CRM for Microsoft Office Outlook with Offline Access client while it is offline.
public property IsInTransaction Gets a value indicating if the plug-in is executing within the database transaction.
public property IsOfflinePlayback Gets a value indicating if the plug-in is executing as a result of the Microsoft Dynamics CRM for Microsoft Office Outlook with Offline Access client transitioning from offline to online and synchronizing with the Microsoft Dynamics CRM server.
public property IsolationMode Gets a value indicating if the plug-in is executing in the sandbox.
public property MessageName Gets the name of the Web service message that is being processed by the event execution pipeline.
public property Mode Gets the mode of plug-in execution.
public property OperationCreatedOn Gets the date and time that the related System Job was created.
public property OperationId Gets the global unique identifier of the related System Job.
public property OrganizationId Gets the global unique identifier of the organization that the entity belongs to and the plug-in executes under.
public property OrganizationName Gets the unique name of the organization that the entity currently being processed belongs to and the plug-in executes under.
public property OutputParameters Gets the parameters of the response message after the core platform operation has completed.
public property OwningExtension Gets a reference to the related SdkMessageProcessingingStep or ServiceEndpoint.
public property PostEntityImages Gets the properties of the primary entity after the core platform operation has been completed.
public property PreEntityImages Gets the properties of the primary entity before the core platform operation has begins.
public property PrimaryEntityId Gets the global unique identifier of the primary entity for which the pipeline is processing events.
public property PrimaryEntityName Gets the name of the primary entity for which the pipeline is processing events.
public property RequestId Gets the global unique identifier of the request being processed by the event execution pipeline.
public property SecondaryEntityName Gets the name of the secondary entity that has a relationship with the primary entity.
public property SharedVariables Gets the custom properties that are shared between plug-ins.
public property UserId Gets the global unique identifier of the system user for whom the plug-in invokes web service methods on behalf of.
Advertisement