copy table record with child records to another table record also with child records
I want top copy a "quote" record that has child lines "quotelines' into a new table record "multiJob" that will also have the copied records "Joblines".
but I am not quite getting the script right (or ninox is mis behaving)
lines 1 to 5 works as stand alone code as creates the parent record etc.
but adding the copy/create child records tripping me up = and i cant quite see what i am doing wrong
so any pointers would deffo be useful (it is bound to be a silly thing!)

copy from - quote record
Quote (parent) quotelines (child records)
into Jobs record
Multijobs (parent) JobLines(child records)
let source := this; copy Quote into 'source' variable
let tgt := (create MultiJobs); create tgt variable fro parent record
tgt.(Customers := source.'Acc Link'); copy the stored account info in quote relationship into multijobs relasonship field
tgt.('Quote Ref' := source.'QteNum'); copy the quote numnnet into quote ref filed in new record
tgt.(Status := 1); and set status to a new job
for li in source.QuoteLines do loop to copy all sub child records
let newLI := create JobLines create the new sublines
newLI.(MultiJobs := tgt); link new child lines to parent record
write the line field info
newLI.(
Qty := li.Qty; etc etc forr all fields rerquired to store info from quotes/childlines
)
end
26 replies
-
Fred - I am going to have to come back to you on this. At the moment I can't quite get my head around your suggested code and as to how that will sit in my script
I need a quiet evening and lots of coffee to understand what yiour script is doing to make sense to me!
your code
let productRec := record(Products,number(Pcode)) let vFileName := item(split(productRec, "/"), 1); let vShare := shareFile(productRec.Image); ItemImage := importFile(this, vShare, vFileName); unshareFile(vTable, "vFileName")
my code
if Pcode then
'Short Description' := record(Products,number(Pcode)).text(Category);
Qty := record(Products,number(Pcode)).Qty;
Description := record(Products,number(Pcode)).Description;
CostEach := record(Products,number(Pcode)).Cost;
SellEach := record(Products,number(Pcode)).Sell;
Supplier := record(Products,number(Pcode)).Supplier;
ItemImage := record(Products,number(Pcode)).ItemImage;
Mkup := (SellEach - SubCost) / SubCost * 100;
SellFlag := false
else
'Short Description' := null;
Qty := 1;
Description := null;
CostEach := null;
SellEach := null;
Supplier := null
end
Content aside
- 16 hrs agoLast active
- 26Replies
- 63Views
-
4
Following
