Skip to main content
This topic is closed to new replies. Start a new post to keep the conversation going.

7 replies

Inspiring
October 7, 2016

I would use 2 document level functions. The first would combine the fields but not include any field with a null value and include a separator value as needed. The other function would bet the field object and report any field that could not found by name.

https://www.dropbox.com/s/lqwo2clnb7pfjar/Concatinate%20Name%20and%20Address.pdf?dl=0

Concatenate Name and Address

This approach avoids extra spaces or other separators when there are fields with null strings for a value.

Translate
Participant
October 6, 2016

// Get the field values, as strings

var First_Name = getField("First_Name").valueAsString;

var Middle_Name = getField("Middle_Name").valueAsString;

var Last_Name = getField("Last_Name").valueAsString;

// Combine values, separated by a space

if(getField("Middle_Name").value == ""){

    event.value = First_Name + " " + Last_Name

}

else {

    event.value = First_Name + " " + Middle_Name + " " + Last_Name

}

This goes into the calculate> Custom Script and this script is if you don't have a middle name it wont look funny

Translate
Participant
October 6, 2016

I see what you did there, and the attention to the middle name is a nice touch, but something's not quite right. The field is coming up empty.

Translate
Inspiring
October 6, 2016

Check the JavaScript console by pressing Ctrl + J to see if there are any errors.

Translate