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!
14 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.
-
Hello Fred! hope you're still listen! I tried many loop for a new purpose after the duplicate button. Without success... When I have my new vessel with its news options in my vessel table (thanks to your script) , I would also like to link all those newly created options to an existing record in my Offer table. Maybe in the same script as the duplicate button, so in one shot I could duplicate a vessel and link its options to an existing offer or to a new one if it is too complicated script to access a dedicated record in the offer table... thanks again for your help!
-
said:
I have to link one by one all the vessel’s options to the offer (I hope it is clearer in the map table screenshots) to see them in the template. Reason why I look for a script which can duplicate a vessel and its options and link them to the Offers to Options table directly.Oh, yes the old print engine. I'm trying to learn the new Carbone print engine (dynamic printing). It is not easy, but not impossible. You might want to look into it. Especially the creation of json data so you can populate the print layout with just the necessary data.
Ninox was asked if they were going to make a more user friendly print engine and the CEO said that they are happy with the Carbone solution and want to spend their time on the DB engine so don't hold your breath for any changes to the print engine.
Along that route, what others have done in the past is what you were thinking about the Printing Template. What you would do is have a print button that would delete all previous records, then copy all necessary data from your data tables into new temporary records in the printing template. Then print from the Printing table. In your case there would be a child table to capture all the options.
Now that I'm done with my babbling, a change to your code to do what you ask.
let t := this; let newRec := duplicate(t); for loop1 in t.Options do let newOp := duplicate(loop1); newOp.( Navire := newRec; Offres := t.Offres2 ) end; Offres2 := 0
This is still at the Navire table with a new reference field called Offres2.
If you want to go back and do this to old Offres then at the Offres table you can add a button that has:
let t := this; for loop1 in Navire.Options do Offres := t end
Content aside
- Status Answered
- 1 yr agoLast active
- 14Replies
- 208Views
-
3
Following