I build this form (a timesheet) where I have a dynamic table with variable number of rows (I'm adding instances with a click on a button).
All rows contain a totalLinhaRelatorio field, this is a time field, and I need all such fields to be added to get a final total.
So I tried these two script lines (FormCalc):
var finalTotal = sum(Time2Num(parteInferior.atividades.tabelaAtividades.linhaAtividade [*].totalLinhaRelatorio[*],"HH:MM"))
$.formattedValue = Num2Time(finalTotal, "HH:MM")
It doesn´t work as I had expected. The field gets correctly just the value from the first row.
I've tried other combinations, such as linhaAtividade.totalLinhaRelatorio[*] and linhaAtividade[*].totalLinhaRelatorio but nothing seems to work.
I think that you will need to loop through the instances in FormCalc. The trouble I suspect is that you can't use the wildcard in the Time2Num function that is then wrapped within the sum function.
Thank you once again!
Reason: the fields that must be added are time fields and it is a lot easier to work with FC than JS with those guys.
You're welcome Marcos!
Have a look at the syntax here:
Hope that helps,
I've just given up trying to figure out how FormCalc treats time calculations and will do it in JS. Thus your material will come in really handy!
Yes, I will have to create my own time calculation functions, no big deal.
What I still haven't figured out, thoughm, is how to cast strings into integers in JS. Should be as simple as parseInt() or Number(), but for some reason its not working.
The loop is possible, its just that I have never gone down the FormCalc route.
Also, the Number() works for me. For example, where I am referencing a string variable in a function:
Ha! it worked!! Please, don't ask...
Now, yes, the loop works perfecly in FormCalc; only the time field calculations in FC is really weird, so I will be better off writing my own function and using your excellent material on SOM Expressions!
Thank you so much!
Europe, Middle East and Africa