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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Event Handler Doesn't get Parameter

(0) ShareShare
ReportReport
Posted on by 563

Dear All,

I have an issue on my code

My event handler doesn't get parameter

Here is my code and variable on debugger

event-handler-doesnt-get-parameter.png

I add the event handler on update method

event-handler.png

I just full compile and full cil but didn't solve the issue

Please kindly give me an advice and solution

Thanks in advance

Best Regards,

Bintang

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    239,647 Most Valuable Professional on at

    You forgot to tell us, but the second screenshot suggests that the handler is attached to update() method of PurchTable table. Is it the case?

    The first screenshot highlights _args.getThis(), therefore I assume there is the problem. What happened? Does it execute without error but it returns an empty record?

  • Bintang Profile Picture
    563 on at

    Hi Martin Dráb,

    Yes it attached to update method on PurchTable

    It execute (compile) without error,  but _args.getThis() can't get purchTable, always return empty record like you said

    event-handler-doesnt-get-parameter-2.png

    Here is I attached when debugger is running

    I don't know what's wrong on my code

    Any suggestion?

  • nmaenpaa Profile Picture
    101,172 Moderator on at

    What about the other event handler for the update method, do you see PurchTable buffer there if you debug? Could you share the code of the other event handler, too?

    In your latest screen shot we do not see the call stack - could you share that too? Just to double check it's coming from PurchTable/update.

  • Bintang Profile Picture
    563 on at

    Hi Nikolaos Mäenpää,

    All right one by one

    Here is the code for sendEmailAfter

    public static void sendEmailAfter(XppPrePostArgs _args)
    {
        PurchTable purchTable, purchTableUpdate;
    
        purchTable = _args.getThis();
    
        try{
    
            //Bintang Check if Status Confirmed send email
            if(purchTable.DocumentState == VersioningDocumentState::Confirmed && purchTable.EmailSent == VDI_YesorNo::No){
                //filename = this.getFileReport(this.PurchId);
                purchTable.sendEmail(purchTable.PurchId);
    
                update_recordSet
                    purchTableUpdate
                    setting
                    EmailSent = VDI_YesorNo::Yes
                    where
                    purchTableUpdate.PurchId == purchTable.PurchId;
            }
        }
        catch{
            error("Could not send email, please ask support");
        }
    }


    and this is from another event handler (afterConfirmPO), attached to update method on PurchTable and PurchLine

    public static void afterUpdatePurchaseOrderLine(XppPrePostArgs _args)
    {
        Common common = _args.getThis();
    
        VDI_PurchTableCustomGridHandler purchTableGridUpdate;
        purchTableGridUpdate = VDI_PurchTableCustomGridHandler::newFromTable(common);
        purchTableGridUpdate.run();
    }


    When I debug  afterConfirmPO (afterUpdatePurchaseOrderLine), _args.getThis() gets data from PurchLine, but can't get data from PurchTable.

    Here is the screenshot

    event-handler-doesnt-get-parameter-4.png

    event-handler-doesnt-get-parameter-4.png

    Is there any problem with PurchTable?

  • Martin Dráb Profile Picture
    239,647 Most Valuable Professional on at

    It works fine in my environment.

    A side note: your catch statement won't work if update() is called in a transaction.

  • nmaenpaa Profile Picture
    101,172 Moderator on at

    Bintang, could you share the call stack for the PurchTable event handlers?

    Also do you have any customization in the PurchTable/update method itself?

  • Bintang Profile Picture
    563 on at

    Dear Martin Dráb,

    Do you have any suggestion?

    It's my first time using event handler

  • Bintang Profile Picture
    563 on at

    Dear Nikolaos Mäenpää,

    Here is the call stack on debugger

    event-handler-doesnt-get-parameter-6.png

    Customization on update method just declaration variable

    event-handler-doesnt-get-parameter-6.png

  • Suggested answer
    nmaenpaa Profile Picture
    101,172 Moderator on at

    Based on the call stack you are updating purchase line in the user interface, not purchase table. Does your event handler work if you actually change the values of purchase order header and save?

  • Bintang Profile Picture
    563 on at

    Dear Nikolaos Mäenpää ,

    It's the same , last time I changed Language on Header View Purchase Order but still doesn't get PurchTable as a parameter from _args

    On the other process , I have update_recordset to PurchTable too

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 24

#2
Michel ROY Profile Picture

Michel ROY 14

#3
Jagadabi Profile Picture

Jagadabi 6

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans