web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

How to get the Execution order of a plugin step (Rank) in Plugin context?

Arun Vinoth Profile Picture Arun Vinoth 11,615 Moderator
Sometimes we may have multiple plugin steps registered on the same message and stage  to divide & achieve the business logic in code Flow. So the execution order can be configured to do it. What if there is some deployment mistake & someone unknowingly changed the execution order? I wonder if the Rank ie. Execution order of a plugin step can be accessed when the code is getting executed.

Microsoft documentation says:
Execution OrderSpecifies 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.
But there is no away to access the Rank from Plugin Execution Context. Still there is a will there is a way!

Solution:

You can do an extra retrieve service call to pull the details from sdkmessageprocessingstep entity record.

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

This investigation started based on this Stack Overflow question

I got to know about this snippet from Steve answer in this community thread

This was originally posted here.

Comments

*This post is locked for comments