Table Parameter: Derived records

Since Windows version 1.0.3.2, tables have the derived records option. In practice, this option tells the program that when the form is opened it must not read the data directly from the table but, through some of its specific values, from another table.

This mainly works around one of the constraints of the Nios4 system: each data display section can only have one associated table. With this option you can, for example, show in a calendar the data derived from both a rapportiintervento (service reports) table and a manutenzione (maintenance) table. When the data is opened, the system shows the form of one or the other, even though the section has a single linked table.

Once the option is enabled, you need to add a post-save script on all the tables you want to show in this one. The script creates the record to be shown and sets the values the system will use to open the actual form.

---------------------------------------  
 --derived record management  
 ---------------------------------------  
 rigacl = nil  
 tabella = database.getsql("SELECT * from attivita WHERE tap='manutenzione' AND gguidp='" .. dataview.getvalue("gguid") .. "'")  
 if tabella.countrows() > 0 then  
   righe = tabella.getrows()  
   rigacl = righe[1]  
 else  
   rigacl = database.newdatarow("attivita")  
 end  
 --update the maintenance data on the activity  

 if rigacl ~= nil then  
   rigacl.setvalue("tap","manutenzione")  
   rigacl.setvalue("gguidp",dataview.getvalue("gguid"))  
   rigacl.setvalue("data_inizio",dataview.getvalue("data"))  
   rigacl.setvalue("data_fine",dataview.getvalue("data_fine"))  
   rigacl.setvalue("oggetto","manutenzione")  
   rigacl.setvalue("descrizione",dataview.getvalue("cliente"))  
   rigacl.setvalue("stato","Manutenzione")  
   rigacl.save()
   database.addsyncbox("attivita",rigacl.getvalue("gguid"))   
 end  

 --refresh the activities section with the new maintenance  
 program.refreshsection("attivita")