Search code examples
pluginsdynamics-crm

In Dynamics CRM is it possible to check the Execution Order from within the plugin context?


When registering a plugin against Dynamics CRM you can specify the Execution Order (also known as Rank).

https://learn.microsoft.com/en-us/previous-versions/dynamics-crm2011/developer-articles/hh237515(v=crm.6)#bkmk_RegStep

Execution Order
Specifies the order, also known as rank, that plug-ins are executed within a pipeline stage. Plug-ins registered with an order value of 1 are executed first, followed by plug-ins registered with an order of 2, and so on. However, if there is more than one plug-in in a stage with the same order value, then the plug-in with the earliest compilation date is called first.

I want to check the value of this from inside the plugin, can I do so, and how?


Solution

  • Yes you can, not directly from Plugin Execution Context but using another retrieve service call.

    var rank = service.Retrieve("sdkmessageprocessingstep",context.OwningExtension.Id,new ColumnSet(new[] { "rank" })).GetAttributeValue<int>("rank");