0

Replicating a value in a different field via a button

Hi all,

I have a master table and a subtable related to each other. Each record on the master record is connected to multiple records in the subtable.

 

For example I have:

- Master record

- Subrecord 1 (including the field X, manually filled)

When I create a subrecord 2, I'd like to have a button that sets the value of my field X in subrecord 2 to the same value included in subrecord 1. Is there any way to make this possible?

 

Many thanks in advance for your support.

 

Best,

Giovanni

6 replies

null
    • John_Halls
    • 2 yrs ago
    • Reported - view

    Hi Giovanni

     

    Use the Trigger on create: in the SubRecord add this line

     

    X:= first(MasterRecord.SubRecord).X

     

    For the first SubRecord it will be ignored, and you can add a value to X manually. For subsequent SubRecords it finds the value of X in the first and adds it to the new record.

     

    Regards John

    • Giovanni_Zagarella
    • 2 yrs ago
    • Reported - view

    Hi John,

     

    Thanks, this is already very useful. However I would a need a formula that fetch the values from the previous record. Something like this:

     

    - Subrecord 1 (manually filled)

    - Subrecord 2 (takes value from subrecord 1)

    - Subrecord 3 (takes value from subrecord 2)

     

    Is there any function similar to first or last, but basically pointing Ninox to the second to last value in its internal sorting?

     

    Many thanks,

    Giovanni

    • Fred
    • 2 yrs ago
    • Reported - view

    Hi Giovanni -

     

    I don't think you can do last-1. Wouldn't that be awesome.

     

    How many subrecordsN do you have to go back?

     

    Is it a static number or does it grow as your DB grows?

     

    If it is static, then couldn't you duplicate the last record then you would only have to change the last subrecord field?

    • John_Halls
    • 2 yrs ago
    • Reported - view

    Hi Giovani

     

    Use this code

     

    let a := MasterRecord.SubRecord;
    X := last(slice(a, 0, count(a) - 1)).X

     

    Regards John

    • Giovanni_Zagarella
    • 2 yrs ago
    • Reported - view

    Hi John,

     

    The formula works perfectly, your help is really appreciated. Have a great day!

     

    All the best,

    Giovanni

    • Alain_Fontaine
    • 2 yrs ago
    • Reported - view

    Hi John,

    Brilliant solution! Will keep it in mind for solving the "last - 1" puzzle…

Content aside

  • 2 yrs agoLast active
  • 6Replies
  • 327Views