0

trigger a field in subtable from field in mother table

I have a field named "Consegna" in a table called "Jobs" and it has 3 options "fast, standard, custom". There is also a "Data" field which indicates the project date. I have a sub-table called "Lavorazioni" in which there is an "Data scadenza" field. I would like to make sure that when the "Consegna" field is changed, a date in "Data scadenza" is entered in relation to the selection. I made this formula but it doesn't work:

Lavorazioni.('Data scadenza' := if Jobs.'Ordini e Pagamenti'.Consegna = 2 and Jobs.Tipo = 1 then
        Jobs.Data + 15
    else
        if Jobs.'Ordini e Pagamenti'.Consegna = 1 and Jobs.Tipo = 1 then
            Jobs.Data + 120
        else
            if Jobs.'Ordini e Pagamenti'.Consegna = 1 and Jobs.Tipo != 1 then
                Jobs.Data + 15
            else
                if Jobs.'Ordini e Pagamenti'.Consegna = 2 and Jobs.Tipo != 1 then
                    Jobs.Data + 7
                end
            end
        end
    end)

4 replies

null
    • Fred
    • 1 yr ago
    • Reported - view

    try adding:

    let t := this;
    

    at the first line and then replace all instances of Jobs after the "then" with t. So line two would look like:

    t.Data+15
    

    The reasoning, I think is, is that while you have to use Jobs in your filter because you are going back up the chain, when it is time to set the data you have to have access to only one record's data, thus the need for the this statement.

      • giuseppe
      • 1 yr ago
      • Reported - view

      Fred Thank you!! Unfortunately it doesn't work. I tried but obviously I did something wrong

    • Fred
    • 1 yr ago
    • Reported - view

    What does your new code look like? Can you put it in a button so you can trigger it on your command?

    With something so complicated, can you create a new field and simplify it. Something like:

    Lavorazioni[Jobs.'Ordini e Pagamenti'.Consegna = 2 and Jobs.Tipo = 1 ]
    

    So you can see if you get any results.

      • giuseppe
      • 1 yr ago
      • Reported - view

      Fred Hi Fred, thanks for your interest. I double-checked everything and corrected the addressing errors and now it works! Thanks!

Content aside

  • 1 yr agoLast active
  • 4Replies
  • 68Views
  • 2 Following