0

Indirectly link N:1 records

Hello !

I have a table named "Comptes", a table named "Activitiés" and a last one named "Bilans de vitalité".

When I create a new record in the "Activités" table, from an existing record in the "Comptes" table, the N:1 field is automatically filled in with the following code:

let me := this;
let newRec := (create 'Activités');
newRec.(Compte := me);
popupRecord(newRec)

It also works when I create a new record on the "Bilans de vitalité" table, from an existing record in the "Activitiés" table, the N:1 field is automatically filled in with the following code:

let me := this;
let newRec := (create 'Bilans de vitalité');
newRec.('Activités' := me);
popupRecord(newRec)

Where I'm stuck is to automatically link a record from the "Comptes" table to the "Bilans de vitalité" table knowing that between the 2, the link can only be made with the "Activitiés" table because saving the "Bilans de vitalité" table can only be done with the button present on the "Activitiés" table.

The Activités table has an N:1 relationship with the "Comptes" table and an N:1 relationship with the "Bilans de vitalité" table.

I would therefore like to know if it is possible to retrieve the link with the "Comptes" table from a record in the "Activités" table to also link the record from the "Comptes" table to the new "Bilans de vitalité" record which has was created from a record in the "Activitiés" table?

I hope I was clear enough, it seems difficult to explain in writing.

 

 

3 replies

null
    • Créateur de bien-être
    • Sebastien_Guillet
    • 1 yr ago
    • Reported - view

    To explain my request more simply, I would like the "Comptes" linked to the "Activités" record to also be automatically added to the new "Bilan de vitalité" record when I click on the "Créer un bilan de vitalité" button. Along the same lines as what the code below can do :

    newRec.('Compte' := me);
    

    The term "me" doesn't work in this specific case and I don't know how to adapt the code.

    • Créateur de bien-être
    • Sebastien_Guillet
    • 1 yr ago
    • Reported - view

    Finally I succeeded. Here is the code if it can help other people.

    let me := this;
    let Account := Compte;
    let newRec := (create 'Bilans de vitalité');
    newRec.('Activités' := me);
    newRec.(Comptes := Account);
    popupRecord(newRec)
    
      • Fred
      • 1 yr ago
      • Reported - view

      Sébastien Guillet Awesome work to figure it out on your own!

      To help expand your knowledge you can simplify your code by using the power of “this” in line 1.

      let me := this;
      let newRec := (create 'Bilans de vitalité');
      newRec.('Activités' := me);
      newRec.(Comptes := me.Comptes);
      popupRecord(newRec)

Content aside

  • Status Answered
  • 1 yr agoLast active
  • 3Replies
  • 60Views
  • 2 Following