Axapta V/s Me

Yet another blog for Dynamics 365 for Finance and Operations. This blog primarily targets the technical readers. I will be sharing my experience with Dynamics AX using code snippets, errors, and solutions, Tips, and tricks.

Table Event handler methods in Dynamics 365 FO [#Dyn365FO]

Hi Guys,

In my last post Form Event hander methods in Dynamics 365 FO, we discussed different event handlers which available on Form.  Let’s continue this discussion with Table event handler method today.
Let’s see the different type of event handler in today’s post.
You need to add a new class to write the event handler methods. I would recommend adding one class to one table. To make it easy for another developer postfix the name by EH or eventHander or Hander so your teammate can identify if they need to add more business logic than create a new class from scratch.

1. Table onValidateField event handler
[DataEventHandler(tableStr(CustTable), DataEventType::ValidatedField)]
public static void CustTable_onValidatedField(Common sender, DataEventArgs e)

ValidateFieldEventArgs  event = e as ValidateFieldEventArgs ;
CustTable custTable = sender as CustTable;

boolean result = event.parmValidateResult();
result = result && RegNumberValidator_BG::validate(custTable.AccountNum, custTable.RegistrationNumber_BG, CustVendACType::Cust);

2. Table OnValidated event hander (same logic you can try for many other event hander)
[DataEventHandler(tableStr(InventLocation), DataEventType::ValidatedField)]
public static void InventLocation_onValidatedField(Common sender, DataEventArgs e)
InventLocation inventLocation = sender as InventLocation;
ValidateFieldEventArgs fieldArgs = e;
boolean ret;
InventLocation inventLocationLoc;
case fieldNum(InventLocation, field1):
if(inventLocation.BHGWorkerAssociate != '')
<Your code/ business ogic/validation>
<ret = true or false>

Let me know if it helps you or you got some more example.

Follow us on Facebook to keep in rhythm with us. @Facebook

No comments:

Post a Comment


Note: Only a member of this blog may post a comment.