Friday, July 28, 2017

Create Auto number from table method in ax 2012

In this article we will see about how to create auto number sequence when we create row in table. Here is the example to create auto number sequence while create row in table.

public void initValue()
{
    str                _newCode;
    int                max1;
    TaskOne      taskOne;
    super();
    select firstOnly SerialNo from taskOne order by RecId desc;
    if(!taskOne.SerialNo)
    {
        ttsBegin;
        _newCode=strRFix(int2str(1),4, "0");
        this.SerialNo = _newCode;
        ttsCommit;
    }
    else
    {
        ttsBegin;
        max1=str2int(subStr(taskOne.SerialNo,4,4))+1;
        this.SerialNo =strRFix(int2str(max1),4, "0");
        ttsCommit;
    }
}

No comments:

Post a Comment

D365 Extensions: Extend the validateField Method on a Table

In this post I will going to show you, how to extend the validateField method on a table. As example I used the SalesLine, where I will ...