Dear All,
I created a temp table and then want to insert records from another table. but cannot insert, pop up message: "The Sales Line already exists. Identification fields and values: Document Type ='Quote'......"
my codeing is written onAfterGetRecord -
"Sales Line".SETFILTER("Document Type",'Order');
IF "Sales Line".FINDSET THEN
REPEAT
TempSalesLine.INIT;
TempSalesLine."Document No." := "Document No.";
TempSalesLine."No." := "No.";
TempSalesLine.INSERT;
UNTIL "Sales Line".NEXT = 0;
Please help how to solve it, thanks
*This post is locked for comments
You can create a global varialbe for Sales Header and find the record using GET function like
SalesHeader.Get("Sales Line"."Document Type","Sales Line"."Document No.");
You need a Date field in Sales Line table to insert Document Date fied of Sales Header as your temp table is based on Sales Line table.
ex: Shipment Date
then code sample will be
TempSalesLine."Shipment Date" := SalesHeader."Document Date";
Thanks Mohana,
Can I ask one more question?
How can I join the table and insert record into TempSalesLine table?
e.g.
there are two tables Sales Header and Sales Line,
I want to join these two table with SalesHeader.Document Date, SalesLine.Document No.,SalesLine.Amount...etc
and then insert those field into TempSalesLine table.
Can you give me some hints and example?
Thank you very much
Thanks a lot
In which Tables - onAfterGetRecord trigger did you write above code?
Is it Sales Line?
Then you need to move
"Sales Line".SETFILTER("Document Type",'Order');
to OnPreDatItem trigger
and remove FindSet and Repeat code..
The Primary key of Sales Line Doc Type, Doc No. and Line No.
So you have to insert those primary key records must.
Add below code and try..
TempSalesLine."Document Type" := "Document Type";
TempSalesLine."Line No." := "Line No.";
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156