AutoIncrement

omyvadiyaomyvadiya Member Posts: 124
edited 2014-07-07 in NAV Three Tier
Hi,
I have a No. field that must be incremented everytime whenever data is inserted. I follow the link below to increment. But couldn't even find a value in the field.

http://blogs.msdn.com/b/nav/archive/201 ... entmessage

Comments

  • ssinglassingla Member Posts: 2,973
    Can you share the code you have written because the code referred in the blog works perfectly.
    CA Sandeep Singla
    http://ssdynamics.co.in
  • omyvadiyaomyvadiya Member Posts: 124
    Actually the scenario is that i have to copy order lines of 1st sales order
    and then from the 2nd sales order to the third Sales Order. So i have created
    the Line No. to get a sequence like 10,20,30....and so on

    I have created 2 new fields in table:

    1. Line No. (that i want to increment)
    2. No. Series (Table Relation - "No. Series")

    As per the blog i wrote following code:

    1. Line No. - OnValidate

    IF "Line No." <> xRec."Line No." THEN BEGIN
    SalesSetup.GET;
    NoSeriesMgt.TestManual(SalesSetup."Prod. Order Routing Line No");
    "No. Series" := '';
    END;

    2. OnInsert() Trigger:

    IF "Line No." = 0 THEN BEGIN
    SalesSetup.GET;
    SalesSetup.TESTFIELD("Prod. Order Routing Line No");
    NoSeriesMgt.InitSeries(SalesSetup."Prod. Order Routing Line No",xRec."No. Series",0D,"Routing No.","No. Series");
    END;


    3. AssistEdit()


    WITH recProdOrRouLine DO BEGIN
    recProdOrRouLine := Rec;
    SalesSetup.GET;
    SalesSetup.TESTFIELD(SalesSetup."Prod. Order Routing Line No");
    IF NoSeriesMgt.SelectSeries(SalesSetup."Prod. Order Routing Line No",OldrecProdOrRouLine."No. Series","No. Series") THEN BEGIN
    NoSeriesMgt.SetSeries("No.");
    Rec := recProdOrRouLine;
    EXIT(TRUE);
    END;
    END;
  • thegunzothegunzo Member Posts: 274
    First; No. Seriers are used for Code 20 fields only. "Line No." is an integer field.

    If you want to increment "Line No." in code you can look at http://www.dynamics.is/?p=248 and use

    IF "Line No." = 0 THEN
    "Line No." := NextLineNo;

    where NextLineNo is a function similar to the example on my blog.
    ________________________________
    Gunnar Gestsson
    Microsoft Certified IT Professional
    Dynamics NAV MVP
    http://www.dynamics.is
    http://Objects4NAV.com
Sign In or Register to comment.