Skip to main content
cabledude94
Participant
September 6, 2018
Answered

Is there a script that will duplicate the first line of a multi-line form field into a separate SINGLE line form field?

  • September 6, 2018
  • 1 reply
  • 468 views

I'm looking to streamline fill in-able pdf letters my company uses. The multi-line field is for  name and address, with each line separated with a line break (Enter/Return key press). Right now, its setup with the multi-line field for address and a separate single line "Dear..." field that are separately filled in. The single line field also has a script to insert a coma after the user types the addressees name. What I'm looking to do is have a script that will read the first line in the multi-form field (addressees name) and automatically populate that name in the single line "Dear..." field AND preserve the auto population of the coma on the single line field.

This would probably a lot easier to explain and even do myself if I had a working knowledge of Javascript, but I digress...

This topic has been closed for replies.
Correct answer try67

You can use this code as the custom calculation script of the "Dear" field:

var fullAddress = this.getField("NameAndAddress").valueAsString;

if (fullAddress=="") event.value = "";

else event.value = "Dear " + fullAddress.split("\r")[0] + ",";

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
September 6, 2018

You can use this code as the custom calculation script of the "Dear" field:

var fullAddress = this.getField("NameAndAddress").valueAsString;

if (fullAddress=="") event.value = "";

else event.value = "Dear " + fullAddress.split("\r")[0] + ",";