Parent Vs Child Execution Pipeline in MS CRM 4.0

The event execution pipeline architecture provides the capability for a pipeline to initiate the execution of one or more subordinate pipelines in order to process a request. The originating pipeline is known as the “parent” while the subordinate pipeline is called the “child”. Web service method calls typically start a parent pipeline while (internal) platform calls start a child pipeline. Child pipelines only process CreateUpdate, or Delete messages as required by the platform to process the parent pipeline’s message. To determine which message is being processed by a child pipeline, you must enable tracing in Microsoft Dynamics CRM.

When a complex request is processed by a pipeline, the pipeline first executes any registered pre-event plug-ins and the core platform operation. Next, the pipeline starts a child pipeline and temporarily suspends processing until the child pipeline has finished processing its request. Once the child pipeline has completed, the parent pipeline can complete its post-event processing.

Parent and Child Context

Context plays an important role when it comes to parent-child pipeline execution. The context that is passed to plug-ins of the child pipeline will include the parent contextthat was executed immediately prior to the child pipeline’s invocation. This will enable you to track the parent and child pipeline executions and get more information about what is going on

Invocation Source

A plug-in can be registered to be executed from a parent pipeline or a child pipeline. At run time, a plug-in receives information as to how it was invoked through theInvocationSource property of the context that is passed as a parameter to the plug-in.

If you want your plug-in to run regardless of whether a Web service call or an (internal) platform call initiated the pipeline, register your plug-in in a child pipeline. However, do not use the IPluginExecutionContext.CreateCrmService or IPluginExecutionContext.CreateMetadataService methods if you are writing code for a plug-in in that is used in a child pipeline. In a child pipeline, you must instantiate the CrmService or MetadataService manually.


The following code example shows how to create a CrmService proxy for plug-ins that execute in the child pipeline.

/// <param name="context">The execution context that was passed to the plug-in's Execute method.</param>
/// <param name="flag">Set to True to use impersonation.</param>
/// <returns>A CrmServce instance.</returns>
private CrmService CreateCrmService(IPluginExecutionContext context, Boolean flag)
    CrmAuthenticationToken authToken = new CrmAuthenticationToken();
    authToken.AuthenticationType = 0;
    authToken.OrganizationName = context.OrganizationName;

    // Include support for impersonation.
    if (flag)
        authToken.CallerId = context.UserId;
        authToken.CallerId = context.InitiatingUserId;

    CrmService service = new CrmService();
    service.CrmAuthenticationTokenValue = authToken;
    service.UseDefaultCredentials = true;

     // Include support for infinite loop detection.
    CorrelationToken corToken = new CorrelationToken();
    corToken.CorrelationId = context.CorrelationId;
    corToken.CorrelationUpdatedTime = context.CorrelationUpdatedTime;
    corToken.Depth = context.Depth;

    RegistryKey regkey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\MSCRM");

    service.Url = String.Concat(regkey.GetValue("ServerUrl").ToString(), "/2007/crmservice.asmx");
    service.CorrelationTokenValue = corToken;

    return service;

One thought on “Parent Vs Child Execution Pipeline in MS CRM 4.0

  1. Hi i thought that they consolidate pipeline into one in 2011…In Microsoft Dynamics CRM 4.0, there existed a parent and a child pipeline. These pipelines have been consolidated into one pipeline for this release. A pre-event plug-in registered in the parent pipeline of Microsoft Dynamics CRM 4.0 is equivalent to registering in stage 10. A pre-event plug-in registered in the child pipeline of Microsoft Dynamics CRM 4.0 is equivalent to registering in stage 20.

Leave a Reply

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

You are commenting using your 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 )

Google+ photo

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

Connecting to %s