Insert Into table with No Serie attached to it

tompynationtompynation Member Posts: 398
lv_PackingHeader.TRANSFERFIELDS(Rec);
lv_PackingHeader.INSERT;

Rec is from type Sales Header... Basically it just copies all the Bill-To, Sell-to and Ship-to fields to my own Record Packing Header

When i do this: lv_PackingHeader.INSERT(TRUE);
Following code gets executed in Packing Header table:

IF "Packinglist No." = '' THEN BEGIN
SetupTable.GET;
SetupTable.TESTFIELD("Packing Order Nos.");
NoSeriesMgt.InitSeries(
SetupTable."Packing Order Nos.",xRec."No. Series",0D,"Packinglist No.","No. Series");
END;

But this gives an error?

Can i not insert wiht the INSERT(TRUE)?

If so how do i get the new number according to the Number serie?

Answers

  • einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    Please post the error message.
    "Money is likewise the greatest chance and the greatest scourge of mankind."
  • kinekine Member Posts: 12,562
    All depends on how your table works. If you want to assign No. from no. series, you need to use something like that:
    lv_PackingHeader.INIT;
    lv_PackingHeader.VALIDATE("Document Type",<some value>);  //if "Document Type" is part of Primary key
    lv_PackingHeader.VALIDATE("No.",'');//"No." is part of Primary key (may be you have another name)
    lv_PackingHeader.INSERT(True); //will assign the new no.
    
    lv_PackingHeader.TRANSFERFIELDS(Rec,false); //will copy all fields, which are not part of primary key, PK fields will be not overwritten...
    lv_PackingHeader.MODIFY(True);
    
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • tompynationtompynation Member Posts: 398
    Thanks Kine, that code works perfect...
Sign In or Register to comment.