These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Want to display only first 4 characters from another text field

gnrltsao
Registered: Oct 6 2009
Posts: 15
Answered

I have a 1D barcode which currently displays the entire last name. I would like to have it display only the first 4 characters from the field "003_Last Name". Does anyone know how I would go about doing this? Substr doesn't seem to work.

var SSN=this.getField("001_SSN").valueAsString;
var PayGroup=this.getField("059_Pay_Group").value;
var last=this.getField("003_Last Name").value
event.value="*"+SSN+PayGroup+"MF01"+last+"*";

My Product Information:
Acrobat Pro 9.0, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Make sure you're getting the valueAsString and then use substr(0,4)

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

gnrltsao
Registered: Oct 6 2009
Posts: 15
Where would I enter that here? I'm a newbie. Thank you try67.

var SSN=this.getField("001_SSN").valueAsString;
var PayGroup=this.getField("059_Pay_Group").value;
var last=this.getField("003_Last Name").valueAsString;
event.value="*"+SSN+PayGroup+"MF01"+last+"*";
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Replace the last line with:
event.value="*"+SSN+PayGroup+"MF01"+last.substr(0,4)+"*";

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com