Hi guys, Today we see How to write validateField method in Dynamics AX 7, d365.
Check Below class.
class CustTable_Events
{
// Using On Events
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[DataEventHandler(tableStr(CustTable), DataEventType::ValidatedField)]
public static void CustTable_onValidatedField(Common sender, DataEventArgs e)
{
ValidateFieldEventArgs event = e as ValidateEventArgs;
CustTable custTable = sender as CustTable;
}
// Using Post EventHandler
/// <summary>
///
/// </summary>
/// <param name="args"></param>
[PostHandlerFor(tableStr(CustTable), tableMethodStr(CustTable, validateField))]
public static void CustTable_Post_validateField(XppPrePostArgs args)
{
CustTable custTable = args.getThis(); //getting table buffer
FieldId fieldId = args.getArg("p1"); // Variable buffer
boolean ret = args.getReturnValue(); // get return value from standard method
switch(fieldId)
{
case fieldNum(CustTable, AccountNum):
if (strLen(custTable.AccountNum) <= 3)
{
ret = ret && checkFailed("Account number should be more than 3 charecters.");
}
break;
}
args.setReturnValue(ret); // set the return value of this method to standard
}
Keep Daxing!!
No comments:
Post a Comment