Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Answered

Form datasource eventhandler in AX2012

Posted on by 150

When a record is created from the form level and the item id is given then I want the vendor details to be filled automatically based om the item id.

So do i use onintialized eventhandler or initvalue ? 

What is the difference?

Should is use oncreated or oncreating?

What is onactivated used for?

  • Verified answer
    KareemTaima Profile Picture
    KareemTaima 304 on at
    RE: Form datasource eventhandler in AX2012

    use modifiedfeild method on the itemId filed, so if any change happens you can recall the data you want in another fields

  • Verified answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Form datasource eventhandler in AX2012

    Yes you can. By the way, the quickest way to answer "can I?" questions is usually to try it!

  • PrachiGupta97 Profile Picture
    PrachiGupta97 150 on at
    RE: Form datasource eventhandler in AX2012

    Sir can I use the onmodified eventhandler?

  • Verified answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Form datasource eventhandler in AX2012

    For your requirement, you should hook in the modification of itemId field, as Martin wrote.

    About your many questions about differences:

    - onInitialized event is fired after super() call of initValue method

    - onCreated is fired after super() call of create method, onCreating is fired before it

    - onActivated is fired after super() call in active method. If you want to run some logic when active (selected) record changes, this is the place

    Functionally there's no difference whether you write your code in active method or use onActivated event handler. Technically the difference is that you either write on top of the standard code (overlayering) or you hook into events that the standard code provides, and place your code in your own classes.

    In D365FO you can't overlayer so you can only use event handlers or Chain of Command (which doesn't exist in AX2012) when you want to enhance the functionality of the standard objects.

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,235 Most Valuable Professional on at
    RE: Form datasource eventhandler in AX2012

    Initialization happens before users can set the item ID, therefore neither initValue nor onIntialized will help. Most likely you want to run the logic when item ID changes, e.g. in modifiedField() method on the table.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans