Obtain in repeat group a value from another table with calc element and JS code?

Is it possible to obtain a value (number) from another table with this JS method?

I have:

tabla 1 | element 1 (field element type) = fab_proyecto___monto | value = 20
tabla 2 | element 2 (calc element type) = fab_entregables_20_repeat___monto_bruto (repeat group) | value = 20

That is, the value of the element in Table 2 is automatically obtained from the element in Table 1

Thanks for your help
 
Yes - but not really using Javascript.

When you have a Fabrik application you are running code in two places - JS in the browser and PHP on your webserver.

The calc element runs PHP code that you write yourself and runs it on the server. This php code can include SQL to get the value that already exists in table 1 - and the calc code (in simple terms) runs when you load a table2 record in a form, when you save the table2 record from a form and once per row when you display table 2 as a list (though you can turn form load and list off). The php code can also be triggered when you change another field in the form using Ajax.

Which settings you choose depends on what you want to happen and when you want it to happen.

There are numerous examples in the forums of calc code to undertake SQL queries. If you can't find it, say so here and I will copy some code I have that you can use as a starting point.
 
Thanks Sophist for you support.

Can I use the WHERE filter if my table1 is related data from table2?

In this case, what WHERE filter code autocomplete the exact value from element table2?
 
Could you please help me with the WHERE filter format.

My Where filter is not working:

WHERE fab_proyecto.monto = '{fab_entregables___cliente}'

I have the element joindatabase (fab_entregables___cliente). Here I need to filter automatically fab_proyecto___monto by Cliente (fab_proyecto___cliente). These 2 last elements are in the same table: fab_proyecto

upload_2018-4-12_10-44-14.png
 

Attachments

  • upload_2018-4-12_10-42-8.png
    upload_2018-4-12_10-42-8.png
    209.8 KB · Views: 8
You are going along the right track, but without more information about the various fields and what they contain there is insufficient information to determine what you need.

However it may be that you need to use '{fab_entregables___cliente_raw}' which contains the users unique numeric id e.g. 20 rather than '{fab_entregables___cliente}' which contains the name e.g. 'Osiptel'.
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top