Chain of Command vs PostHandlerFor in D365 Finance & Operations SSRS Reports

By Deovandski Skibinski | April 3, 2026

X++ PostHandlerFor vs CoC Extension Usage on DP Classes

When you need to push and/or manipulate fields into an SSRS report dataset in Dynamics 365 Finance & Operations (D365 F&O), you typically end up in one of two places:
  • Option A: Wrap the DP method with Chain of Command (CoC)
  • Option B: Attach a PostHandlerFor event handler to the DP’s processReport

This blog walks through both approaches, outlines when to use each, and the key behaviors.

Option A — Chain of Command

Chain of Command (Coc) "code extension" is the preferred approach when it’s available. CoC lets you wrap public/protected methods in an extension class and run code before/after base logic by calling next. Microsoft explicitly positions this as the way to extend logic without event handlers. For more detail, refer to Microsoft's documentation on method wrapping with Chain of Command and extensibility attributes.
Key Behaviors:
  • You must callnext (except replaceable cases) and you can run logic before or after it.
  • CoC applies only if the method is wrappable (e.g., not blocked byfinal or[Wrappable(false)]).
  • CoC is generally easier to follow/debug and behaves like a controlled “method wrapping” pipeline.
[ExtensionOf(classStr(SalesInvoiceDP))]
final class SsiSalesInvoiceDP_Extension
{
    public void processReport()
    {
        next processReport();
        SalesInvoiceTmp invoiceTmp = this.getSalesInvoiceTmp();

        ttsbegin;

        while select forUpdate invoiceTmp
        {
            // TODO Perform custom operation
            invoiceTmp.update();
        }

        ttscommit;
    }

}

Option B — PostHandlerFor on processReport

This approach is typically used when CoC isn’t viable or when you need more loosely coupled post‑processing logic.
Post/Pre handlers exist for backward compatibility and for cases where delegates aren’t published widely. Microsoft's documentation also warns they’re fragile: parameter changes, signature changes, or changed call conditions can break them. 
Key behaviors:
  • You don’t call next. The base method already ran (post) or hasn’t run yet (pre).
  • You access state via XppPrePostArgs and args.getThis(). 
  • You have less explicit control of composition and ordering than CoC, and it can break more easily across updates. 
class SsiSalesInvoiceDPHandler
{
    [PostHandlerFor(classStr(SalesInvoiceDP), methodStr(SalesInvoiceDP, processReport))]
    public static void SalesInvoiceDP_Post_processReport(XppPrePostArgs args)
    {
        SalesInvoiceDP dp = args.getThis() as SalesInvoiceDP;
        if (!dp)
        {
            return;
        }

        SalesInvoiceTmp invoiceTmp = dp.getSalesInvoiceTmp();

        ttsbegin;

        while select forUpdate invoiceTmp
        {
            // TODO Perform custom operation
            invoiceTmp.update();
        }

        ttscommit;
    }

}

Final Thoughts

Choosing between Chain of Command and PostHandlerFor comes down to extensibility, stability, and long‑term maintainability. When Chain of Command is available, it’s typically the safer and more predictable option, while PostHandlerFor remains useful for edge cases and legacy scenarios.

If you’re unsure which approach is right for your reporting or customization needs, the Stoneridge Support Team can help evaluate your requirements and recommend a solution.

Talk to a Stoneridge expert today CTA Button

Deovandski Skibinski
Our Verified Expert
Deovandski Skibinski

Deovandski Skibinski is a developer with experience across multiple programming languages and recent expertise in X++ development for Dynamics 365 Finance and Supply Chain. He brings a passion for problem solving client challenges and enjoys sharing knowledge with fellow developers. His work spans retail, distribution, inventory, and finance, where he builds reliable, efficient solutions that help businesses run smarter. Deo holds a bachelor’s degree in Computer Science from North Dakota State University.

Read More from Deovandski Skibinski

Related Posts


Under the terms of this license, you are authorized to share and redistribute the content across various mediums, subject to adherence to the specified conditions: you must provide proper attribution to Stoneridge as the original creator in a manner that does not imply their endorsement of your use, the material is to be utilized solely for non-commercial purposes, and alterations, modifications, or derivative works based on the original material are strictly prohibited.

Responsibility rests with the licensee to ensure that their use of the material does not violate any other rights.

Start the Conversation

It’s our mission to help clients win. We’d love to talk to you about the right business solutions to help you achieve your goals.

Subscribe To Our Blog

Sign up to get periodic updates on the latest posts.

Thank you for subscribing!