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)

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

I have the same question (0)
  • Suggested answer
    Mea_ Profile Picture
    60,284 on at

    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().

  • DanAx Profile Picture
    on at

    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.

  • Verified answer
    Mea_ Profile Picture
    60,284 on at

    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.

  • Suggested answer
    Community Member Profile Picture
    on at

    Hello

    I also had this problem but fortunately solved it.

    You can use the following:

    "ttsbegin;

    r.myCustomField ='1234';

    ttscommit:"

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