Copy link to clipboard
Copied
Dear all:-)
I never thought it could be so complicated to put an simple If/else statement in a pdf form 😉
Initial situation:
- There are 3 columns in a table: target, actual and delta.
- All associated fields are formatted as "numbers".
- The user enters amounts in the target and actual fields, the delta is calculated automatically.
Task:
- Adding a column 4 called "Delta> 3%"
- Whenever the (calculated) delta is> 3% of the target value, a "x" should be written in the column, otherwise do nothing (or rather overwrite an existing "x").
My considerations:
Var A = this.getField("delta1").value;
Var B = this.getField("Target1").value;
Var C = this.getField("delta1").value / this.getField("Target1").value;
If (C > 0.05) { this.getField("deltabigger5").value = "×";}
else {this.getField("deltabigger5").value = "";}
Unfortunately, when I enter that, nothing happens. The field remains empty, regardless of which values I enter in delta1 or Soll1.
I also don't get any error messages (syntax). Can someone help me and tell me why? Where is the mistake?
Copy link to clipboard
Copied
Your code is working fine.
If you have code in your script like you posted here, replace Var with var and If with if.
Also if you have other calculation in your file, check "Field calculation order" when you select prep form tool
select "More"->Field calculation order.
You are using var so no need to write full path for fields you can use like this:
var A = this.getField("delta1").value;
var B = this.getField("Target1").value;
var C = A/B;
if (C > .05) { event.value = "×";}
else event.value = "";
(event.value is field where you use calculation in this example "deltabigger5")
Copy link to clipboard
Copied
You have errors in your code. Check the JS Console and you should see them.
Also, you have to make sure that the divisor (B, in this case) does not equal zero, as that would result in an invalid calculation (division by zero) and will yield Infinity as the result.