Copy link to clipboard
Copied
Hi!
I'm trying to get a field to print a true or false answer. The field is supposed to get data from another field (which is a summary field) and state if its 65 or above and then print if it is or not.
I have tried the following script but cannot get it to work.
{
if (this.getField(” Summa ATS 1”) == 65 = true);
if (this.getField(” Summa ATS 1”) < 65 = true);
if (this.getField(” Summa ATS 1”) > 65 = false);
{
if (true) System.out.println(" True ");
if (false) System.out.println(" False ");
}
How can I get this to work?
Copy link to clipboard
Copied
There are several major mistakes in your code.
First of all, the "=" operator is used for assigning a value, not for comparisons.
Also, you should not use curly quotes in your code. Only straight ones (single or double, doesn't matter).
In addition, you should not put a semi-colon after an if-statement. It basically renders it useless. It should be followed either by a single line of code or by a block of code, surrounded by curly brackets, which are executed when that expression is true.
You should also be aware that any logical operator will always return a Boolean value, that is either true or false, so there's no need to add an additional check to check if it's true...
This line:
if ((a==b)==true)
Is identical to this line:
if (a==b)
PS. Just noticed another problem. You're only accessing the fields themselves, not their values...
Copy link to clipboard
Copied
Hi!
Thank you for the answer.
I guess this code should be right then:
if (this.getField("Summa ATS 1").value < 64)
{
System.out.println("OK")
}
But it doesn't print "OK"!?
Copy link to clipboard
Copied
From where are you executing the code?
Are there any error messages?
Copy link to clipboard
Copied
No error messages, but still not the result I'm after.
Don't know if this print screen helps, it's in Swedish.
Copy link to clipboard
Copied
Can you share the file itself, via Dropbox, Google Drive, etc.?
Copy link to clipboard
Copied
Sure I can.
Via Google Drive, who to invite?
Copy link to clipboard
Copied
See the comment above. You're using incorrect commands (this is JavaScript, not Java!).
Try it again using console.println() and if it still doesn't work make the file public and post the link to it here.
Copy link to clipboard
Copied
I am not familiar with "System.out.println ()" in Acrobat JavaScript. There is the :console.println ()" to print to the JavaScript console or the "app.alert ()" for a pop-up message.
Do you get any error message on Acrobat's JavaScript console?
You should be using JavaScript statements. Acrobat does not use Java which is a very different language.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now