I have to copy record from a tableA of CompanyA into same tableA of companyB.
I am using command TRANSFERFIELDS so that record of tableA from companyA is transferred into the tableB of companyB - this works as expected.
I need to add also tableB which is basically a linked table to tableA, but I can’t workout how to link another table to the source table. I tried to crate a local function of CU50011 and PAGEn from where I run below code which is inside a CU50011.
This is the code and transferres record into the selected company as expected:
JobTaskRec.CHANGECOMPANY(CompanyTo); //copy record in another company
JobTaskRec.TRANSFERFIELDS(SourceJobTask); //user’s record to be copied
And, now I need to copy also records of linked tableB and I am lost on linking records from TableA to TableB.
Can you advice me how to link table to source table so that I can transfer also records of linked table, too?
Sorry, but I lost the idea for the TableB. I can see “I am using command TRANSFERFIELDS so that record of tableA from companyA is transferred into the tableB of companyB” and can read “I need to add also tableB which is basically a linked table to tableA”. You need to select information for the TRANSFERFIELDS either from tableA or tableB.
Hi, I have copy record from tableA and also linked record on tableB.
I hope it’s understandable, now.
Sorry, but I don’t understand because I can see TableB 2 time => you need to select 1 table for the TRANSFERFIELDS and transfer “manually” for 2nd table
I have now resolved all the issues, except this one.
In the codeunit this code is inserted on OnRun trigger:
//Transfers a record of Job (always only 1 record). This is header table
//Finds all records of linked table to header table. SlourcJobTaskF is linked table
SourceJobTaskF.SETRANGE("Job No.",SourceJob."No."); //SourceJob is header table
IF SourceJobTaskF.FINDSET THEN
UNTIL SourceJobTaskF.NEXT = 0;
This means that SourceTable is the header table with only 1 records of the job (project) and in lines of the project (job) there are 3 records (entries).
Code sets the range to those 3 records as expected, but when all 3 recrods are transferred I get an error:
Microsoft Dynamics NAV
The Job Task already exists. Identification fields and values: Job No.=’’,Job Task No.=’’
There were 1 blank record in the line table, and I deleted it, but still the error pops.
Can you advice me on what else to check?
just to update. Work as expected, I re-run the test and works as expected.
it is good that your code works and it is OK
P.S. 1 small remark - I can see you use different (JobToRec.TRANSFERFIELDS(SourceJob) and TargetJobTaskF.TRANSFERFIELDS(SourceJobTaskF,FALSE) ), but not the same record (table) like you wrote before
It is the same, I renamed it to more meaningful name.
it is not the same for code - you use “another instance”