Generate "No.Series" in CODEUNIT ??

pskannaapskannaa Member Posts: 138
HI,
I want to generate the "Insp.No" automatically in CODEUNIT. Im bit confusing on this because i have already done for the same in table level i.e onInsert(),onValidate() using No.Series management.

But my constraint is, im going to INSERT the Records through the Code in HEADER & LINE part values.
I have declared the initial value in "No.Series" table.

Suggestion Plz..

Regards,
Psk

Comments

  • DenSterDenSter Member Posts: 8,304
    The standard way to implement No. Series is to put the code in OnInsert, and when you create a new record you initialize the record, Clear the "No." field and then do an INSERT(TRUE) so that the code runs. For Header/Line tables, you only put this in the header table, and the lines are differentiated by way of a "Line No." field, which is a simple integer type field.

    If the standard numbering series functionality is not what you want for one particular case, then I suggest you write something specifically, and not try to modify the numbering series logic. This is used throughout the application, and you'd have big issues to solve if you modify that behaviour.
  • kinekine Member Posts: 12,562
    pskannaa wrote:
    HI,
    I want to generate the "Insp.No" automatically in CODEUNIT. Im bit confusing on this because i have already done for the same in table level i.e onInsert(),onValidate() using No.Series management.

    But my constraint is, im going to INSERT the Records through the Code in HEADER & LINE part values.
    I have declared the initial value in "No.Series" table.

    Suggestion Plz..

    Regards,
    Psk

    If the header have automatic numbering, you need only to fill the record and insert it with calling triggers to have the record with new assigned no. If you need to assign the number for another reason in another way, just look how the no. is assigned in some table with automatic numbering and take it as template (e.g. Item table).
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • pskannaapskannaa Member Posts: 138
    Excellent !! Thanks u buddy..It's Working..

    i Put..

    In Header:
    myRec.Init;
    myRec.No := ' ';
    ...
    ...
    myRec.INSERT(TRUE);

    In Line:
    myRecLine.No := myRec.No;...
    ...
    ...
Sign In or Register to comment.