Skip to main content
bryanp88839111
Inspiring
April 9, 2018
Answered

How do I change the field color of a field if calculated amount is negative?

  • April 9, 2018
  • 1 reply
  • 1540 views

I have a field that calculates the difference between two other fields.

For example: [totalfield]= [field1]-[field2]. 

I would like the field to be green if the number in [totalfield] is a positive number.

Likewise, if the number in [totalfield] comes out as a negative number, I would like the field to change to red.

Right now, in [totalfield] I have done a simplified notation formula to subtract the two.

How do I implement the calculation and the code for the color of the field into one?'

Thanks!

This topic has been closed for replies.
Correct answer bryanp88839111

OK, then as the custom validation script of the field enter this code:

event.target.textColor = (event.value>=0) ? color.green : color.red;


I actually want to change the color of the field not the text color.

I tried this:

event.target.fillColor = (event.value>=0) ? color.green : color.red;

but now I can't see the number in that field when turns red, but I can see it when it's green.

1 reply

try67
Community Expert
Community Expert
April 9, 2018

What about if it's zero?

bryanp88839111
Inspiring
April 9, 2018

if it's zero, it would be okay to be green too

try67
Community Expert
Community Expert
April 9, 2018

OK, then as the custom validation script of the field enter this code:

event.target.textColor = (event.value>=0) ? color.green : color.red;