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

    • Daniel_Berrow
    • 2 mths ago
    • Reported - view

    Are you trying to duplicate a Navire record but reset the options that are linked with it, to then create its own options?

      • frsalabert.1
      • 2 mths ago
      • Reported - view

       hello Daniel: thanks for your help! i want navire to keep all its option and navire.duplicated getting the same option... like a clone!

    • Fred
    • 2 mths ago
    • Reported - view

    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

    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.

      • frsalabert.1
      • 2 mths ago
      • Reported - view

      thanks Fred! I will try it!

      • frsalabert.1
      • 2 mths ago
      • Reported - view

       it just works!! you're awesome!!... i need to study my loop function right now!

Content aside

  • Status Answered
  • 2 mths agoLast active
  • 5Replies
  • 67Views
  • 3 Following