In Dynamics Ax 2012, customization on table methods is done by simply overriding them, but in Dynamics 365, we use data event handlers to customize business logic on table methods, and control the behaviour of methods by using two types of events:
1) Proceeding Event ( that occurs before the method’s super() is called)
2) Succeeding Event (that occurs after the method’s super() is called)
For example, the insert method has two events:
1) OnInserting(Preceding Event that occurs before the record is inserted into CustTable)
2) OnInserted(Succeeding Event that occurs after the record is inserted into CustTable)
To use data event handlers, use the following steps:
1) Create a class named “CustTableEventHandler.”
2) Open CustTable, and expand the events node as shown in the below screenshot:
3) In the events node, right-click on the event named “OnInserting”, and select “Copy Event handler Method.”
4) Now paste it into your class named “CustTableEventHandler”, as shown in the below screenshot:
5) Now, let’s say we have a scenario in which we must default some value in the table’s field before insertion takes place. We will modify the code as shown in the below screenshot:
6) Now build the code and run. You will see whenever some record is inserted into CustTable, its field named “ShippingCompany” is defaulted to the value “USPS”.
USA408 365 4638
1301 Shoreway Road, Suite 160,
Belmont, CA 94002
Whether you are a large enterprise looking to augment your teams with experts resources or an SME looking to scale your business or a startup looking to build something.
We are your digital growth partner.
Tel:
+1 408 365 4638
Support:
+1 (408) 512 1812
COMMENTS ()
Tweet