Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

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
Level 3
Level 3

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?

2 Replies
radzmar
Level 10
Level 10

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

akgrimes
Level 3
Level 3

Thank you SO much! I just could not figure out that code. I am so not a coder.