Tuesday, February 3, 2015

Validation For contract parameter value at run time in ax 2012

// Validate Method For contract parameter value at run time in ax 2012

class ClassName implements SysOperationValidatable
{
    TransDate   fromdate;
    TransDate   ToDate;
}

public boolean validate()
{
    boolean             condition = true;

    if (!fromdate)
    {
        condition = checkFailed("From Date should be entered");
    }

    if (!ToDate)
    {
        condition = checkFailed("To Date should be entered");
    }

    if (condition && (fromDate > ToDate))
    {
        condition = checkFailed(strfmt("From Date should be less than or equal to To Date", date2StrUsr(fromDate, DateFlags::FormatAll), date2StrUsr(toDate, DateFlags::FormatAll)));
    }

    return condition;
}

No comments:

Post a Comment

Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...