Highlighted

Logical OR not working

New Here ,
Aug 24, 2020

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;
}
TOPICS
Create PDFs

Views

60

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Logical OR not working

New Here ,
Aug 24, 2020

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;
}
TOPICS
Create PDFs

Views

61

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 24, 2020 0
Contributor ,
Aug 25, 2020

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 25, 2020 0
Adobe Community Professional ,
Aug 25, 2020

Copy link to clipboard

Copied

Try this:

 

if (count == 2 || (score > 5 && score <= 10)) {

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 25, 2020 0
New Here ,
Aug 25, 2020

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 25, 2020 0
Adobe Community Professional ,
Aug 25, 2020

Copy link to clipboard

Copied

What value for score?

 

Info: the first if makes no sense.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 25, 2020 0
New Here ,
Aug 25, 2020

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 25, 2020 0
Adobe Community Professional ,
Aug 25, 2020

Copy link to clipboard

Copied

What statement want you show?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 25, 2020 0
New Here ,
Aug 25, 2020

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).

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 25, 2020 0
Adobe Community Professional ,
Aug 25, 2020

Copy link to clipboard

Copied

The first "if" makes sense when you add a "else" before the second "if".

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 25, 2020 0