- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2023 04:29 PM
I have some styles on Incident caller field when it is a VIP, and it works perfectly.
Now, I am trying to modify & use this script in my scoped application, it gives an error "onChange script error: TypeError: $ is not a function function () { [native code] }".
This is my onChange script.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
var callerLabel = $('label.x_cerr2_ism.caller_id');
var callerField = $('sys_display.x_cerr2_ism.caller_id');
if (!callerLabel || !callerField)
return;
if (!newValue) {
callerLabel.setStyle({backgroundImage: ""});
callerField.setStyle({color: ""});
return;
}
g_form.getReference('caller_id', vipCallerCallback);
}
function vipCallerCallback(caller) {
var callerLabel = $('label.x_cerr2_ism.caller_id').down('label');
var callerField = $('sys_display.x_cerr2_ism.caller_id');
if (!callerLabel || !callerField)
return;
//check for VIP status
if (caller.vip == 'true') {
var bgPosition = "95% 55%";
if (document.documentElement.getAttribute('data-doctype') == 'true')
bgPosition = "5% 45%";
callerLabel.setStyle({backgroundImage: "url(images/icons/vip.gif)", backgroundRepeat: "no-repeat", backgroundPosition: bgPosition, paddingLeft: '30px' });
callerField.setStyle({color: "red"});
} else {
callerLabel.setStyle({backgroundImage: ""});
callerField.setStyle({color: ""});
}
}
I have "Isolate script: false"
Is there anything to do for a scoped application? Did I miss anything?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2023 06:46 PM
Hi,
You'd need to create a system property within your scope for this. Please reference this thread for assistance: https://www.servicenow.com/community/developer-forum/isolate-script-false-and-dom-manipulation-not-w...
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2023 06:46 PM
Hi,
You'd need to create a system property within your scope for this. Please reference this thread for assistance: https://www.servicenow.com/community/developer-forum/isolate-script-false-and-dom-manipulation-not-w...
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!