Notifications

96 views

Symptoms


-- onChange client script is throwing error on the form: 'onChange script error: ReferenceError: <fieldname> is not defined function () { [native code] }

 

-- Here is the example of the script that is throwing the error:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
g_form.getReference('caller_id',setColor);
}
function setColor(caller) {
var callerforField = g_form.getElement('sys_display.' + g_form.getTableName() + '.caller_id');
if (openedFor.vip == 'true')
openedForField.setStyle({color : "red"});
else
openedForField.setStyle({color : ""});
}

Release


Jakarta, Kingston, London

Cause


-- Issue is happening as the script is written to expect 1 variable rather than an array to be returned for:

var callerforField = g_form.getElement('sys_display.' + g_form.getTableName() + '.caller_id');

-- The result is returned in an array because form has two 'Caller' fields.

Resolution


There can be two solutions based on the requirement:

1. If duplicate fields are added on separate sections or same section accidentally removing duplicate fields will resolve the issue.

2. If there is a need to have two fields on the form, script need to be modified to work with the array:

var callerforField = g_form.getElement('sys_display.' + g_form.getTableName() + '.caller_id')[0];

 or

var callerforField = g_form.getElement('sys_display.' + g_form.getTableName() + '.caller_id')[1];

 

Article Information

Last Updated:2018-10-21 11:25:55
Published:2018-10-21