Copy link to clipboard
Copied
I have created a form in which there is a text field "TotalPoints" that is a calculated value of five fields above it.
In another field, I want to show the rating description based on the number of points:
If TotalPoints >9, then "HIGH" (in red letters)
else If TotalPoints <7 then "LOW" (in green letters)
else "MEDIUM" (in orange letters)
How do I do this??
TIA ~ Michelle
You can use the following code as the custom calculation script of the "description" field:
var totalPoints = Number(this.getField("TotalPoints").valueAsString);
if (totalPoints<7) {
event.value = "LOW";
event.target.textColor = color.green;
} else if (totalPoints<=9) {
event.value = "MEDIUM";
event.target.textColor = ["RGB", 1, 0.64, 0];
} else {
event.value = "HIGH";
event.target.textColor = color.red;
}
Copy link to clipboard
Copied
You can use the following code as the custom calculation script of the "description" field:
var totalPoints = Number(this.getField("TotalPoints").valueAsString);
if (totalPoints<7) {
event.value = "LOW";
event.target.textColor = color.green;
} else if (totalPoints<=9) {
event.value = "MEDIUM";
event.target.textColor = ["RGB", 1, 0.64, 0];
} else {
event.value = "HIGH";
event.target.textColor = color.red;
}
Copy link to clipboard
Copied
Just amazing! Thank you so much. Where can I find a list of color codes to use? This "color.green" is a bit to light, but when I look at the codes on the text color properties in the form, the RGB color for this green is 0, 255, 0.
UPDATE** I figured it out, saw another post on converting RGB colors for work in JS (basically, color # divided by 255). I also realized that I didn't take into account when the form is blank or has a 0 result. In those times, the green LOW was appearing since it was <7, Using your format, I carefully edited to add a <1 condition resulting in a blank " " and removed the color line. Again, thank you so very much!
Copy link to clipboard
Copied
Would I do something similar to this if I wanted an if then statement for a subtraction problem? I have a document I converted to a form and it has TotalCharges and TotalCredits. I want to subtract the credits from the charges and put the total on the BalDue field if >=0 and on the Refund line if it is < 0. How would I make the number red and with parenthesis for the refund?