Copy link to clipboard
Copied
How do I populate field 1 with the amount from field 2 based on the description of field 3? I am new to java script and so far I have placed in the calculate tab
if (description == “Single Life”) this.getField(amount);
Needless to say this does not work.
Any help is appreciated.
Copy link to clipboard
Copied
As the custom calculation script of field 1 you can use this code, for example:
if (this.getField("description").valueAsString=="Single Life") event.value = this.getField("amount").value;
else event.value = "";
Copy link to clipboard
Copied
thank you very much - worked like a charm!!
Copy link to clipboard
Copied
For that to work, the custom calculation script for field 1 would have to be something like:
// Get the field values
var sDesc = getField("description").valueAsString; // string
var nAmount = getField("amount").value; // number
// Set this field value
if (sDesc === "Single Life") {
event.value = nAmount;
} else {
event.value = ""; // Blank this field
}
You can add "else if" blocks to handle other cases, or use the "switch" JavaScript statement instead, which is what I'd recommend.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now