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.