D365/AX7:Customizing & Writing Event Handler “onValidatedField” Of Table using switch statement of FieldId


Customizing & Writing Event Handlers Of Table in Microsoft Dynamics D365/AX7. Validating table field values using switch statement of FieldId

Sample Code

[code language = “cpp”]

[DataEventHandler(tableStr(PurchLine), DataEventType::ValidatedField)]
public static void PurchLine_onValidatedField(Common sender, DataEventArgs e)
PurchLine purchLine = sender;
ValidateFieldEventArgs validateFieldEventArgs = e as ValidateFieldEventArgs;
boolean ret = ValidatefieldEventargs.parmValidateResult();

if (ret)
switch (validateFieldEventArgs.parmFieldId())
case fieldNum(PurchLine, ItemId):
InventTable inventTable = InventTable::find(PurchLine.itemId);
if (InventTable.ACXPOType != PurchLine.purchTable().ACXPOType)
ret = checkFailed(‘Purchase Order Header PO Type Should Be Same As Item PO Type’);
ret = ValidatefieldEventargs.parmValidateResult(ret);


Leave a Reply