Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

OnInserting not firing on a table

(0) ShareShare
ReportReport
Posted on by

I've added a few fields through a table extension, when a record is inserted into the table I want to populate those fields with some data prior to the insert.

I've created a static class and added the event to it, but it doesn't fire, My breakpoint in visual studio never gets hit and the data doesnt show up in the table.  I've done all of the normal, database sync, reboot, etc.

static class MyRetailGiftCardTransactionsEventHandlers

{
[DataEventHandler(tableStr(RetailGiftCardTransactions), DataEventType::Inserting)]
public static void RetailGiftCardTransactions_onInserting(Common sender, DataEventArgs e)
{
RetailGiftCardTransactions r = sender as RetailGiftCardTransactions;
r.myCustomField ='1234';
}

}

Anyone have any input?

*This post is locked for comments

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: OnInserting not firing on a table

    Hello

    I also had this problem but fortunately solved it.

    You can use the following:

    "ttsbegin;

    r.myCustomField ='1234';

    ttscommit:"

  • Verified answer
    Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: OnInserting not firing on a table

    You definitely need to go back to MS and ask for extension points. That is the issue they have and they need to fix it. As a stupid work around you can do post handler to RetailGiftCardTable::createCard, set the fields and call update, it's extra DB call but you have no other choice.

  • DanAx Profile Picture
    DanAx on at
    RE: OnInserting not firing on a table

    Thanks for answering ievgen, I can get a prehandler for the add method but that doesn't buy me much as far as I can tell.  Any other suggestions?  I'm calling retailtransactionservice which in turn calls retailtransactionservicetransactions so I'm having some trouble getting to that object.

  • Suggested answer
    Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: OnInserting not firing on a table

    Hi Daniel Budimir,

    Thats probably because retail guys do not like inserts, they do "doInsert" because of some strange reason, so your event won't be triggered.  You need to find a place where record gets inserted into DB and add your code there, it could be multiple places, cross references and debugger will help you. One of them is RetailGiftCardTransactions::add().

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey Pt 2

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,569 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans