Skip to main content
December 8, 2016
Answered

Value entered does not match the format of the field - Button event

  • December 8, 2016
  • 1 reply
  • 476 views

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?

This topic has been closed for replies.
Correct answer try67

You don't need any of that. Just use this:

this.getField("CompletedValue").value = X;

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
December 8, 2016

You don't need any of that. Just use this:

this.getField("CompletedValue").value = X;