Copy link to clipboard
Copied
Hi,
I have the follow boxes to calculate the risk of a work process,
I want to be able to change the background colour of the fields in the R (Risk) fields based on the following conditions:
L = Green
M = Yellow
H = Red
VH = Red
below is the current script I have in the R (Risk) fields
var L = this.getField("LPreparation").valueAsString;
var C = this.getField("CPreparation").valueAsString;
var R = L+C;
if(R=="A1"||R=="B1"||R=="B2"||R=="C2"||R=="D3"||R=="D4"||R=="E3"||R=="E4"||R=="E5")
event.value = "M";
else if(R=="C1"||R=="D1"||R=="D2"||R=="E1"||R=="E2")
event.value = "L";
else if(R=="A2"||R=="A3"||R=="B3"||R=="B4"||R=="C3"||R=="C4"||R=="D5")
event.value = "H";
else if(R=="A4"||R=="A5"||R=="B5"||R=="C5")
event.value = "VH";
else
event.value = "";
Would be grateful if anyone can assist with the conditional formatting
Copy link to clipboard
Copied
You can do it like this:
var L = this.getField("LPreparation").valueAsString;
var C = this.getField("CPreparation").valueAsString;
var R = L+C;
if(R=="A1"||R=="B1"||R=="B2"||R=="C2"||R=="D3"||R=="D4"||R=="E3"||R=="E4"||R=="E5"){
event.target.fillColor = color.yellow;
event.value = "M";}
else if(R=="C1"||R=="D1"||R=="D2"||R=="E1"||R=="E2"){
event.target.fillColor = color.green;
event.value = "L";}
else if(R=="A2"||R=="A3"||R=="B3"||R=="B4"||R=="C3"||R=="C4"||R=="D5"){
event.target.fillColor = color.red;
event.value = "H";}
else if(R=="A4"||R=="A5"||R=="B5"||R=="C5"){
event.target.fillColor = color.red;
event.value = "VH";}
else{
event.target.fillColor = color.white;
event.value = "";}
To see color, you will have to turn off fields highlight in Edit⇾Preferences⇾Forms and uncheck 'Show border hover color for fields'. If other users use the file, they will have to do the same on their software also.
Or since it's a calculated field you can set it to read only, that will remove highlight also.
Copy link to clipboard
Copied
You can do it like this:
var L = this.getField("LPreparation").valueAsString;
var C = this.getField("CPreparation").valueAsString;
var R = L+C;
if(R=="A1"||R=="B1"||R=="B2"||R=="C2"||R=="D3"||R=="D4"||R=="E3"||R=="E4"||R=="E5"){
event.target.fillColor = color.yellow;
event.value = "M";}
else if(R=="C1"||R=="D1"||R=="D2"||R=="E1"||R=="E2"){
event.target.fillColor = color.green;
event.value = "L";}
else if(R=="A2"||R=="A3"||R=="B3"||R=="B4"||R=="C3"||R=="C4"||R=="D5"){
event.target.fillColor = color.red;
event.value = "H";}
else if(R=="A4"||R=="A5"||R=="B5"||R=="C5"){
event.target.fillColor = color.red;
event.value = "VH";}
else{
event.target.fillColor = color.white;
event.value = "";}
To see color, you will have to turn off fields highlight in Edit⇾Preferences⇾Forms and uncheck 'Show border hover color for fields'. If other users use the file, they will have to do the same on their software also.
Or since it's a calculated field you can set it to read only, that will remove highlight also.
Copy link to clipboard
Copied
Amazing! Thank you so much for this!
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more