Saturday, October 31, 2015

AX 2012:Date Conversion

Date Conversion

public boolean validateField(FieldId _fieldIdToCheck)
{
    boolean ret;
    str     datestr;

    ret = super(_fieldIdToCheck);

    ret = super(_fieldIdToCheck);
        if (ret)
        {
            switch (_fieldIdToCheck)
            {
                case fieldnum(LTMortgage, ValidTo) :
                    datestr = Date2Str(this.ValidTo,123,2,3,2,3,4);
                    if (datestr!= "" && this.ValidTo <= this.ValidFrom)
                    {
                        ret = checkFailed('ValidTo date should be greater than ValidFrom date');
                    }
                break;
                case fieldnum(LTMortgage, ValidFrom) :
                    datestr = Date2Str(this.ValidFrom,123,2,3,2,3,4);
                    if (datestr!= "" && this.ValidFrom >= this.ValidTo)
                    {
                        ret = checkFailed('ValidFrom date should be less than ValidTo date');
                    }
            break;
            }
        }

    return ret;
}

I am getting following best practice when I write following code

Date2Str(<date>,123,2,3,2,3,4)

BP error : "dateflag should be specified when calling date2str"

how to resolve this Best practice.

resolved this BP when added DateFlags::None

No comments:

Post a Comment

Table browser URL in D365FO

Critical Thinking icon icon by Icons8