Skip navigation
Currently Being Moderated

Adding field values in multiple rows in a dynamic table

Jan 9, 2012 9:15 AM

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

 
Replies
  • Currently Being Moderated
    Jan 9, 2012 11:32 AM   in reply to Marcos J Pinto

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 10, 2012 11:18 AM   in reply to Marcos J Pinto

    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?conte nt=000211.html.

     

    Hope that helps,

     

    Niall

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 12, 2012 8:06 AM   in reply to Marcos J Pinto

    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

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points