• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Logical OR not working

Guest
Aug 24, 2020 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

404

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
community guidelines
Enthusiast ,
Aug 25, 2020 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.

Votes

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
community guidelines
Community Expert ,
Aug 25, 2020 Aug 25, 2020

Copy link to clipboard

Copied

Try this:

 

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

 

Votes

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
community guidelines
Guest
Aug 25, 2020 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.

Votes

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
community guidelines
Community Expert ,
Aug 25, 2020 Aug 25, 2020

Copy link to clipboard

Copied

What value for score?

 

Info: the first if makes no sense.

Votes

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
community guidelines
Guest
Aug 25, 2020 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.

Votes

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
community guidelines
Community Expert ,
Aug 25, 2020 Aug 25, 2020

Copy link to clipboard

Copied

What statement want you show?

Votes

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
community guidelines
Guest
Aug 25, 2020 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).

Votes

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
community guidelines
Community Expert ,
Aug 25, 2020 Aug 25, 2020

Copy link to clipboard

Copied

LATEST

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

Votes

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
community guidelines