web
You’re offline. This is a read only version of the page.
close
Skip to main content
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
    237,512 Most Valuable Professional on at
    RE: Event Handler Doesn't get Parameter

    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
    RE: Event Handler Doesn't get Parameter

    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,160 Moderator on at
    RE: Event Handler Doesn't get Parameter

    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
    RE: Event Handler Doesn't get Parameter

    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
    237,512 Most Valuable Professional on at
    RE: Event Handler Doesn't get Parameter

    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,160 Moderator on at
    RE: Event Handler Doesn't get Parameter

    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
    RE: Event Handler Doesn't get Parameter

    Dear Martin Dráb,

    Do you have any suggestion?

    It's my first time using event handler

  • Bintang Profile Picture
    563 on at
    RE: Event Handler Doesn't get Parameter

    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,160 Moderator on at
    RE: Event Handler Doesn't get Parameter

    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
    RE: Event Handler Doesn't get Parameter

    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Alexey Lekanov Profile Picture

Alexey Lekanov 3

#2
Michele Gozzi Profile Picture

Michele Gozzi 2

#2
Community Member Profile Picture

Community Member 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans