How to add new table to Navision auto numbering

brucembrucem Member Posts: 86
edited 2000-06-10 in Navision Financials
Hi there,

I hve created a couple of table and would like to use the numbering methods as used by navision for things such as sales headers etc ( no series )

i have looked at the current tables, but am stuck as to the steps required to add them to the number series / auto numbering set up.

also i would like to use the rename record function / method to renumber the linekd sub table.

Any ans all help aprreciated

Bruce

Comments

  • Mr_David_CoxMr_David_Cox Member Posts: 15
    Bruce

    Adding No Series to a new "Widget" table

    Step 1
    One of the Setup Tables
    EG: 313: Inventory Setup
    Add a New Field
    50000 "Widget Nos." Type:Code Size:10 Properties:TableRelation = "No. Series"

    Step 2
    To your New Widget Table
    Add a New Field
    50000 "No Series." Type:Code Size:10 Properties:TableRelation = "No. Series"

    C/AL Globals
    Widget Type:Record SubType:Widget
    NoSeriesMgt Type:Codeunit SubType:NoSeriesManagement

    Copy AssistEdit Function from Item Table C/AL Globals
    Change Paramaters on the function to Widget Table

    Table Function:
    AssistEdit(OldWidget : Record Widget) : Boolean
    WITH Widget DO BEGIN
    Widget := Rec;
    InvtSetup.GET;
    InvtSetup.TESTFIELD("Widget Nos.");
    IF NoSeriesMgt.SelectSeries(InvtSetup."Widget Nos.",OldWidget ."No. Series","No. Series") THEN BEGIN
    InvtSetup.GET;
    InvtSetup.TESTFIELD("Widget Nos.");
    NoSeriesMgt.SetSeries("No.");
    Rec := Widget;
    EXIT(TRUE);
    END;

    Code as Follows (Copied from Item Table)

    Table Trigger:
    OnInsert()

    IF "No." = '' THEN BEGIN
    InvtSetup.GET;
    InvtSetup.TESTFIELD("Widget Nos.");
    NoSeriesMgt.InitSeries(InvtSetup."Widget Nos.",xRec."No. Series",0D,"No.","No. Series")
    END;

    Trigger:
    No. - OnValidate()
    IF "No." <> xRec."No." THEN BEGIN
    InvtSetup.GET;
    NoSeriesMgt.TestManual(InvtSetup."Widget Nos.");
    "No. Series" := '';
    END;

    Step 3
    Widget Card (Form)
    "No." Field TextBox C/AL Code

    OnAssistEdit()
    IF AssistEdit(xRec) THEN
    CurrForm.UPDATE;

    Have Fun

    MindSource(UK)Limited
    Navision Service Partner
    info@mindsource.co.uk
    www.mindsource.co.uk
    MindSource(UK)Limited
    Navision Service Partner
    info@mindsource.co.uk
    www.mindsource.co.uk
  • brucembrucem Member Posts: 86
    Grrrreeeat,

    thanks for that. Not quite the same as good old autonumber !!

    Bruce
  • Mr_David_CoxMr_David_Cox Member Posts: 15
    O.K.

    AutoNumbering Types 1 & 2

    Type 1
    New Table "My Table" with Primary Key "Entry No."

    C/AL Globals
    Var MyTable Type:Record SubType:"My Table"

    C/AL Code
    OnInsert ()

    MyTable.RESET;

    // Find Last Record
    IF MyTable.FIND('+')THEN
    "Entry No.":=MyTable."Entry No." + 1
    ELSE
    "Entry No.":=1;


    Type 2
    Table with Existing Multiple Fields in the Primary Key
    Table Named "My Table"

    New Field 50000 Name:"Entry No." Type:Integer
    New Key "Entry No."

    C/AL Global
    Var Name:MyTable Type:Record SubType:"My Table"

    C/AL Code

    OnInsert ()

    MyTable.RESET;
    MyTable.SETCURRENTKEY("Entry No.");
    // Find Last Record
    IF MyTable.FIND('+')THEN
    "Entry No.":=MyTable."Entry No." + 1
    ELSE
    "Entry No.":=1;

    Easy INIT!


    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by brucem:
    Grrrreeeat,

    thanks for that. Not quite the same as good old autonumber !!

    Bruce
    <HR></BLOCKQUOTE>



    MindSource(UK)Limited
    Navision Service Partner
    info@mindsource.co.uk
    www.mindsource.co.uk
    MindSource(UK)Limited
    Navision Service Partner
    info@mindsource.co.uk
    www.mindsource.co.uk
  • John_TegelaarJohn_Tegelaar Member Posts: 159
    Why not use the AutoSplitKey property of the form? This creates a new unique key for a new record at insert. Some conditions have to be met for the Key structure, but that's easy (see Help).

    Some AutoNumbering, after all :-)

    John
Sign In or Register to comment.