0

Get a value from parent table

I'd like to fill automatically some fields of the new records in a subtable. One of the values comes from the parent table (Compositeurs.Solde_redevance) and has to fill the subtable field 'Solde_précédent'.

What is wrong in my syntax (placed in the record creation trigger)?

Year := year(today()) - 1;
let xSolde := Compositeurs.Solde_redevance;
'Solde_précédent' := xSolde

Thank you in advance.

4 replies

null
    • Alain_Fontaine
    • 3 yrs ago
    • Reported - view

    The usual reply is that this kind of script must be placed in the "Trigger after update" option of the reference field, which is only available on the "N:1" side of the relation.

    • Alain.2
    • 3 yrs ago
    • Reported - view

    Hmmm. Some formulae inside the subtable need these values. I'll try to redesign this module... except if somebody has an unusual strategy.

    • Alain_Fontaine
    • 3 yrs ago
    • Reported - view

    In a table/subtable relation, the N:1 reference field is in the subtable. So you can fill fields of the subtable with data from the fields of the main table. But the script to realize the copy must reside in the "Trigger after update" option of the reference field.

    • Alain.2
    • 3 yrs ago
    • Reported - view

    I found the solution: I simply created a button to create the subrecord with the needed values extracted from the previous subrecord. Here is the code for information.

    let currentRec := this;
    let xYear := last(Redevances.'Année') + 1;
    let xSolde := last(Redevances.TotalBrutToReport);
    let i := (create Redevances);
    i.(Compositeurs := currentRec);
    i.('Année' := xYear);
    i.('Solde_précédent' := xSolde)

    Thanks again.

Content aside

  • 3 yrs agoLast active
  • 4Replies
  • 609Views