Skip to main content
doublechamp
Participant
January 27, 2017
Answered

Trailing zeros dropped from field when using barcode

  • January 27, 2017
  • 2 replies
  • 716 views

I have a form that has a text field for a percentage (5 digits with decimal).  If the percent is 100.00, the barcode reads 100.  Is there a way to capture the percentage without the decimal and keep the trailing zeros in the barcode?

Here is what I have tried:

strValues += oParam.oDoc.getField(strFieldName).value.toString().replace(/\./g'');

with results of 100.

Thanks

This topic has been closed for replies.
Correct answer Karl Heinz Kremer

Instead of the value property use the valueAsString property of the field object.

2 replies

Legend
January 27, 2017

So, you want to display the number in "hundredths of percents".

The easiest way would be to multiply the field's value with 100. If you need the preceeding zeroes, you would use the util.printf() method to format the number with preceding zeroes. You may also need the Math.floor() method to cut off remaining decimal digits. And that should do it.

Also, in my understanding of the replace() method, you'd have to separate the Regular Expression and the replacement string with a comma.

And, in this situation it is better to use the valueAsString property, as already mentioned by Karl Heinz Kremer.

Karl Heinz  Kremer
Community Expert
Karl Heinz KremerCommunity ExpertCorrect answer
Community Expert
January 27, 2017

Instead of the value property use the valueAsString property of the field object.