Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / Table OnInserted event
Finance forum

Table OnInserted event

Posted on by Microsoft Employee

Hi,

In table extension class, we have onInserted event.

If we write code in oninserted event and our logic throws any exception, will the record insert be rolled back.

  • Verified answer
    Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: Table OnInserted event

    Then it is definitely executed inside of the transaction. 

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Table OnInserted event

    Hi,

    I tried it.

    Both oninserted and post handler rolls back the insert in case on any error in event handler.

    Thanks.

  • Suggested answer
    Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: Table OnInserted event

    onInserted  happens after record is inserted. There are 2 possible scenarios here:

    1) insert is inside transaction. Any exception in the transaction will terminate it and roll back.

    2) insert is not in the transaction scope. Data would be committed to DB before calling your eventHandler.

  • Verified answer
    Sukrut Parab Profile Picture
    Sukrut Parab 71,647 Moderator on at
    RE: Table OnInserted event

    You should not put event handler in  extension  class. Here is good explanation for that. Also in your scenario , record is not going to be inserted in your table if its in transaction, you can try it yourself for any simple table.

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Table OnInserted event

    You should be able to test it very easily. Please share the results with us. Thanks!

    At least with Chain of Command you can wrap your code and the "next" call in one transaction, in which case any exception inside that transaction will cause everything to roll back.

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans