Interview Questions

Tuesday, May 13, 2014

Create Number Sequence through code in AX

Hi Guys,
              Here I am going to tell you that if you want to create number sequence through code then how you can accomplish this task.

First of all you have to create a table Table1. In this table you have to add one static method.
Code is given below : 

static int64 Method1()
{
    Table1 _table1;
    ;
    select Count(recid) from _table1;
    return _table1.RecId;
}


Now you have to create a form Form1 also,
In this form select Table1 as the datasource of this form.
Now override create method in the datasource. Code is given below.

public void create(boolean _append = false)
{
;
    super(_append);
    Table1.Counter = Table1::Method1()+1;   
}

Now, Synchronize and restore Table1.
Then, Synchronize and Restore Form1.
Now your task is done.

No comments:

Post a Comment