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

Trouble using Concat()

CRobertson
Registered: Feb 2 2010
Posts: 4

I have a form i have created with 3 fields:

Customer Name
Customer Number
Account Number

I have two fields that i need to concatenate with CustNum and AcctNu to have an "*" added to the beginning and end of each.

[img]http://lh6.ggpht.com/_Dv3I7BF8ilU/S2mkkBZwv8I/AAAAAAAAAEQ/kEFd1NcSEkM/PDF_CONCAT.jpg[/img]

My Product Information:
Acrobat Standard 9.0, Windows
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
You are using Acrobat Form Tool and not LiveCycle Designer. 'Concat' is a LiveCycle Designer FormCalc function and not part of the Acrobat JavaScript. You are also not properly accessing the value of the 'CUSTOMER' field object in Acrobat JavaScript.

In Acrobat JavaScript, you use '+' operator for adding number and concatenating strings. But you need to be careful because Acrobat JavaScript makes a guess as to whether it should add or concatenate and frequently makes mistakes in choosing on how to handle each field.

To access a field in Acrobat JavaScript, you need to use 'this.getField("FieldNameStrting")' method and then you can use '.value' or '.vlaueAsString' to obtain the value of field or the string value entered into the field.

There is a special object called the 'event', which is the current field that Acrobat/Reader is focused on and there are a number of properties and methods for this object. '.value' is one of the properties.

So you could use for your custom calculation script:
event.value = '*' + this.getField("CUSTOMER').valueAsString + '*';
A more generalized solution could be created using the 'function' statement.

George Kaiser

CRobertson
Registered: Feb 2 2010
Posts: 4
Perfect...Thank you so much. I spent 3 hours trying to fingure this out before I found this site. I will tell others about it.

Thanks again.