Hi, I am trying to import TAB separated file consist of 4 columns. Each row is a New Sales Order. at the
Integer - Import::OnBeforeInsertRecord() i Wrote the following Code,
SalesHeader.SetHideValidationDialog(TRUE);
SalesHeader.INIT;
SalesHeader."Document Type" := SalesHeader."Document Type"::Order;
SalesHeader.INSERT(TRUE);
but for second record i got Error, that Sales Header already Exists.
Not sure what is wrong in this.
0
Answers
Unexpectedly INIT does not initialize primary key fields - "Primary key and timestamp fields are not initialized.". So, your code should be:
SalesHeader.INIT;
SalesHeader."Document Type" := SalesHeader."Document Type"::Order;
SalesHeader."No." := '';
SalesHeader.INSERT(TRUE);
To get much info about INIT, read https://msdn.microsoft.com/en-us/library/dd354939.aspx