12 July 2018

Table Events and Event handlers in AX 7 / D365

Below example is to create Pre and post event handler for Existing method and second method is a new override method in the CustGroup Table.
class TRCustGroupEventHandler
{

///
///
///

/// [PreHandlerFor(tableStr(CustGroup), tableMethodStr(CustGroup, delete))]
public static void CustGroup_Pre_delete(XppPrePostArgs args)
{
CustGroup custGroup = args.getThis() as CustGroup;
//custGroup.cut
}

///
///
///

/// /// [DataEventHandler(tableStr(CustGroup), DataEventType::ValidatingWrite)]
public static void CustGroup_onValidatingWrite(Common sender, DataEventArgs e)
{
CustGroup custGroup = sender as CustGroup;
}

///
///
///

/// /// [DataEventHandler(tableStr(CustGroup), DataEventType::ValidatedField)]
public static void CustGroup_onValidatedField(Common sender, DataEventArgs e)
{
CustGroup custGroup = sender as CustGroup;
ValidateFieldValueEventArgs ve = e as ValidateFieldValueEventArgs;
boolean ret = ve.parmValidateResult();

if(ret)
{
switch(ve.parmFieldName())
{
case fieldStr(CustGroup,CustGroup):
if(custGroup.CustGroup == "")
{
ret = false;
}
break;
}
}

ve.parmValidateResult(ret);
}
}

No comments:

Post a Comment

Give me the commetns and solutions

Ledger Voucher creation Framework and x++ code to create ledger voucher

 Please click her for MS reference file Below is the out of the box example reference and code. SalesInvoiceJournalPostSubBill_Extension->...