line number creation

b2bteamb2bteam Member Posts: 4
edited 2006-03-02 in Dynamics AX
hi all,

Actually i am trying to insert the records into the customised Table.
which is in the form of Header and line Format.
while i am inserting a New record in the Line Table It is Taking Negetive line Numbers.

but Line No is an extended Datatype and we set the Property of AllowNegetive to No.


Let me know how to Generate Number series Automatically when ever we Insert a new Record Like Purchase Order creation.


Regards,
ramesh.

Comments

  • kinekine Member Posts: 12,562
    Negative lines no? Please, can you send us:

    Primary key of the line table + datatypes of this fields?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    kine wrote:
    Negative lines no? Please, can you send us:

    Primary key of the line table + datatypes of this fields?

    Hey Kamil, wake up! This is an axapta question... Or do you know axapta as wel?
  • kinekine Member Posts: 12,562
    :oops:
    Sorry... ](*,)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • RyuRyu Member Posts: 26
    hi,

    I've the same problem bus me I want to be able to insert or remove lines and that that modifies the classification of the following lines.

    I've not find the response in any forum of AXAPTA

    thank you for your help.
  • MugurMugur Member Posts: 93
    Hi,

    This is easy to do ... supposing you have the 2 tabl;es named HEADER and LINES which are tied through the KEY field, you need to modify 2 methods on the Lines table:

    void Insert()
    {
    Lines customLines;
    ;

    select max(linenum) from customLines where customLines.key = this.key;

    this.linenum = customLines.linenum + 1;

    super();
    }

    void delete()
    {
    int lineNum = this.linenum;
    Key key = this.key;
    Lines customLines;
    ;

    super();

    ttsbegin;
    while select forUpdate customLines
    order by linenum asc
    where customLines.key = key && customLines.linenum > lineNum
    {
    customLines.lineNum = customLines.lineNum-1;
    customLines.Update();
    }
    ttscommit;
    }
    Kind regards,

    Ciprian Dudau
    Axapta Developer
  • MugurMugur Member Posts: 93
    Also, in order to see the lines correctly in the bottom section grid of your form, you need set on the Lines datasource the CounterField property to Linenum (or whatever the counter field name is).


    Hope this helps.
    Kind regards,

    Ciprian Dudau
    Axapta Developer
  • vulamvulam Member Posts: 24
    Hi Mugur.
    please correct me but should we setup a NumberSequence for this sort of job ??. and use the NewGetNum method or NewgetNumFromCode to get the next avaliable number ??.
  • MugurMugur Member Posts: 93
    No, the number sequence have nothing to do with line numbering. Number seq's are used for primary key's generation, and only when those are strings. AFAIK, nowhere in Axapta the linenum is generated as you expect.
    Kind regards,

    Ciprian Dudau
    Axapta Developer
  • RyuRyu Member Posts: 26
    hi Mugur,

    I thank you very much for your answer but unfortunately that doesn't function. :(:( Effect I cant use the maxof for the insert. I've to insert lines and that updates the number of the following lines. In example I want to insert a line between the "3" and the "4" the new line must carry the n°4 and "old the n° 4" must as for it carry number 5.

    I hope that I was more clearly
  • RyuRyu Member Posts: 26
    hi,

    I finally found the code which i were to use automatically to increment the numbers of the lines which was superieures with that that I had just created.. :D:D

    public void initValue()
    {
    MSM_ActiveConfigChoice _ConfigChoice;//form
    ;
    super();

    // CUS-Modification on 02 Mar 2006 by ODRT - Begin LineNum insert or create
    ttsBegin;
    select MaxOf (lineNum) from _configChoice //I selectionne the line highest of my park
    where _ConfigChoice.ServiceObjectId == MSM_ActiveConfigChoice.ServiceObjectId ;
    if (tmpLineNum == _ConfigChoice.LineNum)// TmpLineNum is my line where i'm in my form
    { //if tmp == maxlineNum tmp+1
    MSM_ActiveConfigChoice.LineNum = tmpLineNum +1;
    }
    else
    {
    MSM_ActiveConfigChoice.LineNum = tmpLineNum; //my new line take the numlber of the old
    while select forupdate _ConfigChoice
    where _ConfigChoice.ServiceObjectId == MSM_ActiveConfigChoice.ServiceObjectId &&
    _ConfigChoice.LineNum >= tmpLineNum && _ConfigChoice.Statut_C2A == C2A_StatutLigneParc::Actif
    //i only selectionne the linenum where are superior
    {
    _ConfigChoice.LineNum = _ConfigChoice.LineNum +1;
    _ConfigChoice.Update();// mise à jour dans ma table

    }
    }

    ttscommit;
    // CUS-Modification on 02 Mar 2006 by ODRT - end LineNum insert or create

    I hope this code will be useful for you.
Sign In or Register to comment.