LiveCycle Designer dynamic form/table with repeat rows and calculated total in footer - need code to turn total red if <>100, black if =100

akgrimes 05-10-2017

I have a dynamic form with a table that uses a button with an instance manager to add rows and another to delete rows. The footer row has a field that calculates the total of fields in the rows above, and changes as the user enters entries, add/removes rows, changes entries.

I would love to turn the text of the calculated total to red if it is <> 100, and back to black when it =100.

I've tried all sorts of code in all sorts of events. Sometimes I can get the calculated total to turn red -- but the calculation won't work and it displays as zero. Mostly I just break the calculation and nothing happens at all after that.

Name of field where user enters a number that is totaled in the footer row:

form1.Mainsubform.Tablesubform.Table.TableREPEATROW.UserNumberSubform.UserNumberNumericField

Name of field where total is calculated

form1.Mainsubform.Tablesubform.Table.FooterRow.FooterRowNumericField

Code to calculate the total:

::calculate - (FormCalc, client)

sum(TableREPEATROW[*].UserNumberSubform.UserNumberNumericField[*])

This works fine to calculate the total in the footer. What code will change the font of that total to red if it is <>100 and back to black if it is =100, where do I put it, and is it JavaScript or FormCalc?

Mark Solution

Are these answers useful?
Help other community members by marking useful answers as accepted.

Accepted Solutions (0)

Answers (2)

Answers (2)

radzmar
MVP
05-10-2017

Change the calculate script in the following way:

::calculate - (FormCalc, client)

var s = sum(TableREPEATROW[*].UserNumberSubform.UserNumberNumericField[*])

if (s eq 100) then

    $.font.fill.color.value = "0,0,0"

else

    $.font.fill.color.value = "255,0,0"

endif

$ = s