Copy link to clipboard
Copied
I seem to be having trouble with the logical OR.
In the code below, I get the behaviour I want based on the variable "score". However, I don't get what I am looking for with the "count" variable.
Any help would be greatly appreciated.
// Combined Authorization Criteria
var count = this.getField("HighCount").valueAsString
var score = this.getField("TotalScore").valueAsString
if (score <= 5) {
(this.getField("Authority").value) = "FAO MAY APPROVE";
event.target.textColor = color.green;
}
if (count === 2 || score > 5 && score <= 10) {
(this.getField("Authority").value) = "COS OPS / OC TO APPROVE";
event.target.textColor = ["RGB",0.788,0.800,0.145];
}
else if (count > 2 || score > 10) {
(this.getField("Authority").value) = "CO AUTHORITY TO APPROVE";
event.target.textColor = color.red;
}
else {
(this.getField("Authority").value) = "FAO MAY APPROVE";
event.target.textColor = color.green;
}
Copy link to clipboard
Copied
And what do you want to achive exactly? you need to be specific when coding, for example if score is lower then 5 it will remain green but if it is higher it will change to second statement end you will get COS OP...etc.
Copy link to clipboard
Copied
Try this:
if (count == 2 || (score > 5 && score <= 10)) {
Copy link to clipboard
Copied
Still unsuccessful. It's weird because even if I set "var count = 3" it doesn't return the correct statement.
Copy link to clipboard
Copied
What value for score?
Info: the first if makes no sense.
Copy link to clipboard
Copied
In each case I have tested it to get the counter behaviour I want, score is 9. The condition I've been setting is score = 9 and count = 3.
Copy link to clipboard
Copied
What statement want you show?
Copy link to clipboard
Copied
Under those conditions (score=9 and count=3), I'd like it to return
"CO AUTHORITY TO APPROVE";
How should I change my first "if" statement to make more sense?
My apologies, I am brand new to Javascript (doing it less than a week).
Copy link to clipboard
Copied
The first "if" makes sense when you add a "else" before the second "if".