Copy link to clipboard
Copied
Trying to make cells change color based upon a percentage using validation script in Adobe Acrobat Pro DC. The text field is a calculated value from other text fields in simplified field notation (i.e. Text42/Text44).
Custom Validation Script:
var v = Number(event.value);
v = v.toFixed(2);
if (v<=0.55){event.target.fillColor = color.red;}else if (v>0.55 && v<=0.70){event.target.fillColor = color.magenta;}else if (v>0.70 && v<=0.84){event.target.fillColor = color.green;}else{event.target.fillColor = color.cyan;}
unfortunately, the calculated values all return red. (i.e. 0.94375 gives me a red background).
Any help would be greatly appreciated.
RB
Got it. I had to change every cell that was used to calculate Text42 and change it back. I couldn't just retype the numbers to update. thank you both for helping me trouble shoot!
Copy link to clipboard
Copied
Your code is working fine for me.
Did you check field calculation order?
Copy link to clipboard
Copied
No! I am not sure how to do that?
Copy link to clipboard
Copied
I found it, however, after ensuring the order. I am still getting red.
Copy link to clipboard
Copied
Can you share your file?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Can't download.
Copy link to clipboard
Copied
This link
Copy link to clipboard
Copied
As a test, try getting rid of that second line of code.
Copy link to clipboard
Copied
I actually just added that as a potential fix. It didn't work before either. thank you though!
Copy link to clipboard
Copied
A validation script is triggered when the field value changes, so be sure to change the field value to trigger the code.
Copy link to clipboard
Copied
For me everything works fine.
Copy link to clipboard
Copied
Weird. I still get red cells
Copy link to clipboard
Copied
Check the JavaScript console (Ctrl+J) to see if any errors are reported. Also, try saving the file, closing Acrobat, and reopening to see if it makes a difference.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
While "8.57%" results in cyan, a value of 8.57 results in red. That's a hint.
Copy link to clipboard
Copied
I did find that. When you tested Asim, did you enter raw numbers, or did you use the calculated percentages?
Copy link to clipboard
Copied
because the 62.86 entered in the WorkKeys slot seems to work.
Copy link to clipboard
Copied
Got it. I had to change every cell that was used to calculate Text42 and change it back. I couldn't just retype the numbers to update. thank you both for helping me trouble shoot!