how to use noseries???

suspectsuspect Member Posts: 16
I have a custom table with a key field "number". I would like to have a automatic noseries in this field every time i create a new record, just like it is at sales header. So how could that be done?? :oops:

Comments

  • tinoruijstinoruijs Member Posts: 1,226
    You have to define a field No. Series in the custom table like in Sales Header.
    If you use Developers Toolkit, you could search for "Order Nos." (from Sales & Receivables Setup) and see where it's being used.
    Modify the corresponding custom objects like the "Order Nos."-objects the Developers Toolkit has found.

    Tino Ruijs
    Microsoft Dynamics NAV specialist
  • EugeneEugene Member Posts: 309
    basically u need to

    1) in some setup table "SetupTable" create a field for your number serie "Your Nos." which would have a relation to "No. Series" table

    2) in your table (that you want to auto number records by no serie "Your Nos.") create a field "No. Series". This field will hold the value of no serie "Your Nos." that was used to generate a primary key value for the given record

    3) write the following code in OnInsert trigger of your table (here i assume the primary key consists of one field named "No."):
    IF "No." = '' THEN BEGIN
      SetupTable.GET;
      SetupTable.TESTFIELD("Your Nos.");
      NoSeriesMgt.InitSeries(
        SetupTable."Your Nos.",xRec."No. Series",0D,"No.","No. Series");
    END;
    

    4) in your table's OnValidate trigger for the primary key field "No." write the following code (to allow manual code input along with automatic assignement from no serie):
    IF "No." <> xRec."No." THEN BEGIN
      SetupTable.GET;
      NoSeriesMgt.TestManual(SetupTable."Your Nos.");
      "No. Series" := '';
    END;
    
Sign In or Register to comment.