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
18 replies
-
Hi Mel
Just quickly There’s no semi-colon at the end of line 8
Regards John
-
what if you delete 9 - 12 and just see if the create line works.
can you post a sample db?
-
deffo parent Quotes (for the 'this' part) and child table is QuoteLines
other table is deffo MultiJobs and child is JobLines
-
I re-created your tables and the code is fine
let source := this; let tgt := (create MultiJobs); tgt.(Customers := source.'Acc Link'); tgt.('Quote Ref' := source.QteNum); tgt.(Status := 1); for li in source.QuoteLines do let newLI := (create JobLines); newLI.(MultiJobs := tgt); newLI.(Qty := li.Qty) endNot only that, but it works too
Regards John
-
Multijobs vs MultiJobs ?
-
Hi Fred/John/Stephen
I woke up this morning to find you have proved a solution.
Fred copied your script striaght in to button and hey presto it works.
so THANK YOU BOTH!
However I want to understand exactly where i had gone wrong here ( as was not sure where have i got Mutli-Job-Test? named. so
cup of coffee and a crwal thriugh and found it.
in earlier testing i must of called it this and snice renaned the table but forgot to do this

so firstly - i got confused between talking about this and view names! - Yes - feel very stupid now!
secondly - i need to learn to step back and check and recheck again!
if i was a tenth as good as you good then i guess i would be very good indeed!.
I am going the leab[ve this thread open as i have another tsck durectly connect to this one. in so far as i want to be able to select just some of the child lines to copy over! (Wow!). I have a basic idea of how this can be done using a yes/no tick box on each sub line and the line(s) of script i nned to amend. but i will have a go and post it back here in a few days
So don't rush to tell me the asnwer until it get stuck ! (which i bound be do ha ha )
😄
Content aside
- yesterdayLast active
- 18Replies
- 18Views
-
4
Following





