Hello!
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.
Please, help!!
Marcos
Solved! Go to Solution.
You're welcome Marcos!
Yes, it is possible, but I have never used FormCalc for this, preferring JavaScript. Given that you are using time functions, it makes sense to stick with FormCalc.
Have a look at the syntax here:
http://help.adobe.com/en_US/livecycle/9.0/designerHelp/index.htm?content=000211.html.
Hope that helps,
Niall
Hi Marcos,
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.
There is a discussion here on loops, albeit in JavaScript: http://www.assuredynamics.com/index.php/2011/05/som-expressions/.
Good luck,
Niall
Views
Replies
Total Likes
Hi Niall,
Thank you once again!
Now, all sample codes I've seen dealing with this looping use JavaScript. Is it possible to do the same with FormCalc?
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.
Marcos
Views
Replies
Total Likes
You're welcome Marcos!
Yes, it is possible, but I have never used FormCalc for this, preferring JavaScript. Given that you are using time functions, it makes sense to stick with FormCalc.
Have a look at the syntax here:
http://help.adobe.com/en_US/livecycle/9.0/designerHelp/index.htm?content=000211.html.
Hope that helps,
Niall
Hi Niall,
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!
Thank you!
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.
Marcos
Views
Replies
Total Likes
Hi Marcos,
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:
return Number(cleanedTextField);
Try an console.println() before and after the line of script and see what is happening in the JavaScript Console.
Good luck,
Niall
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!
Marcos
Views
Replies
Total Likes