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)

OnInserted event

(0) ShareShare
ReportReport
Posted on by 4,131

Hi,

I would like to modify the inserted method. The scenario is when the DirPerson record is created, I would like to add to another record based on the current DirPerson information. How can I achieve this? It seems not able to modify the Directory model, and when I create an extension, I can only use the onInserted event handler? But I am not sure how to get the current DirPerson table buffer in the onInserted event handler.

Thanks in advance,

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Basheer17 Profile Picture
    2,720 on at

    [DataEventHandler(tableStr(DirPerson), DataEventType::Inserted)]

    public static void DirPerson_onInserted(Common sender, DataEventArgs e)

    {

          DirPerson dirPerson = sender as DirPerson;

    }

    sender is the current record/buffer.

  • Yuji Profile Picture
    4,131 on at

    Thanks a lot.

  • Yuji Profile Picture
    4,131 on at

    BTW, do I just create a new class and copy this dataeventHandler method to the new class as a method? And this is it, or do I need to do some more modifications on the class.

    Thanks

  • Basheer17 Profile Picture
    2,720 on at

    Yes, you can copy the event handler method in a new class. You don't have to do more modifications. If you want to add new methods to the table then you must create new class and add ExtensionOf attribute. I always keep two separate classes one for extension and one for event handlers. If you wish to keep a single class, that would also be fine.

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