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)

transaction handling in post event handler in AX7

(0) ShareShare
ReportReport
Posted on by 1,330

Hi,

I have an event handler written where i am throwing an error based on condition.

I just want to know whether it would revert the original action which has triggered this event handler? Do I really need to use ttsbegin...ttscommit block in this event handler. 

I want the original action to revert whatever it has done if this post event handler throws an exception anywhere in the code. Even I don't want to write try...catch  block.

I have written this event handler on the 'updated' event of the table.

*This post is locked for comments

  • krishna.rao@dax Profile Picture
    3,026 on at

    Yea, need to use ttsbegin & ttscommit;

    like below..

    ttsbegin;

    //// Business logic

    if (condition)

    throw error (" transactio reverted");

    ttscommit;

  • mail2vd Profile Picture
    1,330 on at

    What about the event that trigger the event handler?

  • krishna.rao@dax Profile Picture
    3,026 on at

    I didn't get you.

    ttsbegin;

    //// Business logic - execution of the business logic

    //here business logic may have events or event handlers.

    ttscommit;

  • mail2vd Profile Picture
    1,330 on at

    i have written post event handler on update method of the table which gets executed after update happens on the table.

    So just want to know what happens to update method code that has already executed before the post event handler exception.

  • Rob vanBrandenburg Profile Picture
    285 on at

    Did you find a solution for this? I have a somewhat similar situation where I need to prevent the user from entering a new record from the table.initfromOtherTable() method (post event handler)

  • Martin Dráb Profile Picture
    240,854 Most Valuable Professional on at

    initFrom* method is a wrong place for validation logic. What about using onValidatingWrite event?

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans