Copy link to clipboard
Copied
First of all, It is not clear to me whether I'm posting this question in the right forum.
I created an interactive fillable form, some fields should be filled by hand, calculations was done in Acrobat Pro to automatically displayed formula results.
Here is what is expected to happen in the red framed fields:
How can I make the Total Price to use If/Then formula, must this be scripted?
Try this code:
var v = Number(this.getField("QTY. Adobe CC complete").value) * Number(this.getField("Unit Price Adobe CC complete").value);
if (this.getField("Request date").valueAsString!="01/06/2017") v = v/2;
event.value = v;
Copy link to clipboard
Copied
Yes, this is the right place, and yes, this can be done using a script.
What format is the date field using?
Copy link to clipboard
Copied
Qty and Unit Price fields are numbers only, while the Request date is dd/mm/yyyy
Copy link to clipboard
Copied
You can use the code given above, then, just add ".valueAsString" after this part: this.getField(" ??Request date?? ")
Copy link to clipboard
Copied
"value" gives the same value.
Copy link to clipboard
Copied
But you didn't include either one in your code, so it's not going to work as-is...
Copy link to clipboard
Copied
OK, I forget it.
Copy link to clipboard
Copied
Thank you both @Bernd Alheit and try67​ for jumping in with the script. Unfortunately I'm getting this error after adding ".valueAsString"
The error reads: SyntaxError: missing ) after condition.
Below is the script I entered.
event.value = this.getField(" ??QTY. Adobe CC complete?? ").value * this.getField(" ??Unit Price Adobe CC complete?? ").value;
if (this.getField(" ??Request date?? ") ".valueAsString" != "01/06/2017") event.value = event.value / 2;
Copy link to clipboard
Copied
Try this code:
var v = Number(this.getField("QTY. Adobe CC complete").value) * Number(this.getField("Unit Price Adobe CC complete").value);
if (this.getField("Request date").valueAsString!="01/06/2017") v = v/2;
event.value = v;
Copy link to clipboard
Copied
Perfect. It worked.
Much appreciate your assistance.
Copy link to clipboard
Copied
You must use the correct field names in the different rows.
Copy link to clipboard
Copied
Just did with another row with different field name, it woks there too after changing corresponding name within the script
Copy link to clipboard
Copied
You must use JavaScript for this:
event.value = this.getField(" ??Qty?? ").value * this.getField(" ??Unit Price?? ").value;
if (this.getField(" ??Request date?? ") != "01/06/2017") event.value = event.value / 2;
In the code you must use the correct field names.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now