Avatar

Level 6

I revised Niall's script some to make it work as a custom calculation script and make it a bit more suitable for an Acroform:

// Get the field values, as strings

var i = this.getField("firstName").valueAsString;

var j = this.getField("lastName").valueAsString;

// Set this field's value if both fields are not blank

// otherwise, set this field to blank

if (i && j) {

     event.value = j + ", " + i.slice(0, 1);

} else {

     event.value = "";

}

(An acroform field value will never be equal to null.)