Create Auto number from table method in ax 2012

Description:-

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 60 _newCode;
    int max1;
    Stamp ObjStamp;
    super();
    select firstOnly StampId from ObjStamp order by RecId desc;
    if(!ObjStamp.StampId)
    {
        ttsBegin;
        _newCode=strRFix(int2str(1),4, "0");
        this.StampId = _newCode;
        ttsCommit;
    }
    else
    {
        ttsBegin;
        max1=str2int(subStr(ObjStamp.StampId,4,4))+1;
        this.StampId =strRFix(int2str(max1),4, "0");
        ttsCommit;
    }
}

Related Posts

Previous
Next Post »

Thanks for comments.....