Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Make An Event Handler To Change Data Inside The Field In The Table Before update() Or Insert() Method

Posted on by 200

Dear Experts,

I'm a developer of dynamics AX 2012 R3.

The goal i want to achieve is to change the data that will be stored in the table when update() or Insert() method executed.

Recently, i make a post event handler that will update a custom field i made inside the PurchTable (Purchase Order) and inside the PurchTableType Class (Purchase Order). but, the table can't be updated because the table buffer i used from the update() method is flagged with forUpdate clause.

here is the Post Event Handler that will activate when update() method in PurchTable Table is called :

public static void afterUpdatePurchaseOrderTable(XppPrePostArgs _args)
{
    Common common = _args.getThis();

    VDI_PurchTableCustomGridHandler purchTableGridUpdate;
    purchTableGridUpdate = VDI_PurchTableCustomGridHandler::newFromTable(common);
    purchTableGridUpdate.run();
}

and below here is the Post Event Handler that will activate when update() method in PurchTableType class is called :

public static void afterUpdatePurchaseOrderClass(XppPrePostArgs _args)
{
    Object object = _args.getThis();

    // select purchTable table buffer from PurchTableTYpe Class
VDI_PurchTableCustomGridHandler purchTableGridUpdate; purchTableGridUpdate = VDI_PurchTableCustomGridHandler::newFromClass(object); purchTableGridUpdate.run(); }

below here is the screenshot taken from the debugging session :

8233.1.JPG

2844.2.JPG

Is there another way that i can try to solve this?

I appreciate any answer, Thanks.

Best Regards,

Chaidir Ali Assegaf

*This post is locked for comments

  • Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: Make An Event Handler To Change Data Inside The Field In The Table Before update() Or Insert() Method

    Hi Chaidir Ali Assegaf,

    To update a table buffer it should be selected for update that is a correct behavior, so could you please explain why you cannot update it?

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans