Copy link to clipboard
Copied
I'm trying to write a script which allows the user to click a button which will perform a calculation and fill in the "CompletedValue" field with the results. The script I've written currently looks like this:
var cV = this.getField("CompletedValue").value;
var pV = this.getField("PresentValue").value;
if (cV.value!='' || cV.value!=null)
{
getField("CompletedValue").value="";
var X = Math.ceil((pV*(100/75))/100)*100;
this.getField("CompletedValue").value = X.ToString;
}
else
{
var X = Math.ceil((pV*(100/75))/100)*100;
this.getField("CompletedValue").value = X.ToString;
}
When I click the button, however, I am getting the error messages "The value entered does not match the format of the field [ CompletedValue ]".
The CompletedValue field is currently formatted to Numbers, 0 decimals & no currency symbol. If I change the format to None, I do not get the error, but the value that shows in my field is 'undefined'.
I've alternatively tried to write (what I believe is) the problem line like this:
this.getField("CompletedValue").value = intParse("X").ToString;
& like this:
this.getField("CompletedValue").value = X.valueAsNumber;
But all of my attempts have resulted in either the error message or the 'undefined' string output. Ideally I would like to keep the CompletedValue field formatted for Numbers, but if it has to have no formatting I can live with that. Any ideas how to resolve this?
You don't need any of that. Just use this:
this.getField("CompletedValue").value = X;
Copy link to clipboard
Copied
You don't need any of that. Just use this:
this.getField("CompletedValue").value = X;
Find more inspiration, events, and resources on the new Adobe Community
Explore Now