Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

AX 2012 R3. How to debug event handlers (delegates)

(0) ShareShare
ReportReport
Posted on by 2,987

Can anyone help me to understand how to identify what X++ event handlers are subscribed to a delegate?


For example, by pure luck, I know that when posting a product receipt, when delegate \Classes\SubledgerJournalizer\recordedSubledgerJournalAccountEntries is called, the code in \Classes\SubledgerJournalizerLedgerVoucherExt\recordedSubledgerEntriesEventHandler is executed. This is because I read in some other forum post.

However, when I place a breakpoint in some other delegate, for example, I can put a breakpoint in delegate \Classes\SubledgerJournalizer\insertingDistributedTmp, but how can I identify what event handler is going to be executed???

Thanks.

*This post is locked for comments

  • Daniel Weichsel Profile Picture
    1,657 on at
    RE: AX 2012 R3. How to debug event handlers (delegates)

    Another tip to see if there are any subscribed handlers is to peek at the $$eventMap member of the class object in the debugger.

  • Ghetz Profile Picture
    2,987 on at
    RE: AX 2012 R3. How to debug event handlers (delegates)

    Indeed, this was what I was trying. However, finally I realized that sometimes a delegate is called, but there is no subscribed event handler, so no aditional code is executed.

    I shall add that once you press F11 in the delegate method and enter the infrastructure classes, you will find this variables:

    xppEvent.numDynamicEventHandlers

    xppEvent.numEventHandlers

    This are integer variables that will tell you the number of currently subscribed event handlers for this delegate. If both are 0, it means there are no event handlers to be executed.

  • Suggested answer
    Martin Dráb Profile Picture
    231,723 Most Valuable Professional on at
    RE: AX 2012 R3. How to debug event handlers (delegates)

    When you step into your delegate in debugger, press Step Into (F11) again. Don't worry that you stay on the delegate header and there is no other code; you'll get into infrastructure classes handling events and ultimately to the event handler itself.

    When you get familiar with it, you can put breakpoints to more specific places, so you don't have to step through all calls.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,865 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,723 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans