Dear all,
need your help on this.
i have a sales buffer table in which i populate sales orders and then move them to sales header table.when the data in the buffer table has some errors it has to mark the particular record as error and move on to the next record.
i wrote the following code but seems that it doesnt work
IF "Sales Header Buffer".FIND('-')THEN BEGIN
REPEAT
"Sales Table".INIT;
"Sales Table"."Document Type" := "Sales Header Buffer"."Document Type";
"Sales Table"."No." := "Sales Header Buffer"."No.";
"Sales Table"."Sell-to Customer No." := "Sales Header Buffer"."Sell-to Customer No.";
"Sales Table".VALIDATE("Sales Table"."Document Date",TODAY);
"Sales Table".LOCKTABLE;
IF NOT("Sales Table".INSERT)
THEN BEGIN
"Sales Header Buffer"."Error":= TRUE;
"Sales Header Buffer".MODIFY(TRUE);
END
ELSE begin
message('Imported Successfully';)
END;
COMMIT;
UNTIL "Sales Header Buffer".NEXT = 0;
END;
any help on this please
0
Comments
You need to insert the code into the codeunit OnRun trigger (or just calling some function from there). If there is any error in the CU, it will return false, if all is ok, it will return true and you can catch these and get the error text to save it somewhere when needed. Just do not forget that it will run as separate transaction...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
i am using NAV 2009
IF NOT "Sales Table".INSERT(TRUE) then BEGIN
.....
When inserting with true - you tricker the insert trigger.
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
i used the codeunit.run() and this was the best way i could achieve it.
thanks again :thumbsup: