NAV
javascript

.setCustomField()

var fieldName = 'Company';
var fieldValue = 'Vandelay Industries';

SnapEngage.setCustomField(fieldName, fieldValue);

Pre-populate any field on your prechat or offline form. (The field is still editable by the visitor.)

For Design Studio users only. Legacy chat users may instead use the .setDescription(), .setUserEmail(), or .setUserName() API methods to pre-populate their non-custom form fields. Custom form users will be able to pre-populate any custom fields on their forms by simply using JavaScript, for example, document.getElementById("myFavoriteColor").value = "blue".

Parameters

Parameter Type Description
fieldName String The field’s name attribute can be found by inspecting the DOM and looking for the input element’s name attribute. In general the name of a field is the field’s label with no spaces, and case-sensitive. For example, if you have a field with a label 'Favorite Color', the name attribute is 'FavoriteColor'.
fieldValue String Provide a value for this field. You can hardcode the value, or pass it as a parameter using JavaScript or server-side scripting.