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
- 
  
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+15The 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.
 - 
  
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.
 
Content aside
- 3 yrs agoLast active
 - 4Replies
 - 74Views
 - 
    2
    Following
    
 
