button for Duplicate a record and its links to a sub table

Hello Community!
I needs some help to create a button in my table Navire.
Each record of Navire has multiple links to another table Options (1:N)
This allow to create a navire with its own options.
Now I would like to create a button which can duplicate a selected navire with all its own options.
It should sound like for a navire x : duplicate(this) where Option:= navire x
But I'm lost with this kind of script.
So help appreciated!
thanks a lot!
5 replies
-
Are you trying to duplicate a Navire record but reset the options that are linked with it, to then create its own options?
-
If you had a button in the Navire table, it would look something like:
let t := this; let newRec := duplicate(t); for loop1 in t.Options do let newOp := duplicate(loop1); newOp.Navire := newRec end
Lines 1 and 2 are probably what you expect.
Lines 3 - 6 is the for loop that takes each related record in Options of the current Navire record and duplicates it then links it to the newly duplicated record in line 2.
Content aside
- Status Answered
- 2 mths agoLast active
- 5Replies
- 60Views
-
3
Following