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

Notifications

Announcements

No record found.

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

I have the same question (0)
  • krishna.rao@dax Profile Picture
    3,006 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,006 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
    237,805 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

Responsible AI policies

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

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans