Sales Lines - Line No Field

HaribabuHaribabu Member Posts: 33
I have designed a xml port through which i import sales orders into Navision.
How can i increment the Line no field in Navision automatically.

I dont want to hardcode the values for the lines that i have
While inserting the lines NAV automatically has to increment the Line no

CAn anyone pls help.

raghu

Comments

  • David_SingletonDavid_Singleton Member Posts: 5,479
    NextLineNo += 10000;
    David Singleton
  • matttraxmatttrax Member Posts: 2,309
    More specifically, you have to setup a hard coded line number to start with. It's not like NAV magically knows to start with 10,000. There is code that tells it to do so.

    You can do that with a variable or you can try to find the last line in your document and add a number to that. Also try doing an INSERT(TRUE) so that you call all the code that's supposed to be executed when you insert into that table.
  • garakgarak Member Posts: 3,263
    Like David's answer.

    Before importing:
    Find the Last Line if the imported Order exist and save this Line No. in a variable (Like NextLineNo)
    If there is no Line No. set NextLineNo to 10000. If there is one NextLineNo := "Line No." + 10000;

    During the import you can increment the variable NextLineNo with NextLineNo += 10000;
    Do you make it right, it works too!
  • David_CoxDavid_Cox Member Posts: 509
    Look at the xmlPort 99008514 - Inbound Sales Order

    This uses a buffer table and a codeunit process converts these records to Sales Orders later.

    There are reasons for this approach one being the code for the line number is not on the Insert Trigger of the 'Sales Line table', so the code has been added on the buffer table, the system also needs good data like the Type, 'No.' and Quantity etc: to be properly tested and validated.

    When these are validated the 'Sales Line' code gets the Sales Header which will not exist during the xml Import, so you may need to re-think the process.

    If you choose not to create a buffer table then to answer your question:
    Create a Global Variable LastLineNo

    Then code on SalesHeader - Import - OnInsert
    LastLineNo := 0;

    Then code on SalesLine - Import - OnInsert
    LastLineNo := LastLineNo + 10000;
    SalesLine."Line No." := LastLineNo;

    I would use a buffer table and import the xml into this, then use a codeunit to test the data, marking any bad records and create the good Orders, to do this copy and modify the xml port and buffer tables that already exists into the custom area as the clients own.

    David
    Analyst Developer with over 17 years Navision, Contract Status - Busy
    Mobile: +44(0)7854 842801
    Email: david.cox@adeptris.com
    Twitter: https://twitter.com/Adeptris
    Website: http://www.adeptris.com
  • HaribabuHaribabu Member Posts: 33
    Thanks .....now it works for me....
Sign In or Register to comment.