while running Client Script : TypeError: $ is not a function
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2018 04:14 AM
Hi All,
We have an issue with service portal. I incident form on urgency field we have added an VIP option. And it should not visible to the end user. But in our case we end user can also see the option VIP.
it is showing an error on browser as "There is a JavaScript error in your browser console" when went to console its showing the below errors
running Client Script : TypeError: g_form.getParameter is not a function. Below is the Client script for this error
function onLoad() {
var view = g_form.getParameter('view');
var hasProblemItil = g_user.hasRole('problem_itil');
if (view == 'major_incidents') {
//hides button if user doesn't have problem_itil role
if (hasProblemItil == false) {
try {
var items = $$('BUTTON').each(function(item){
if(item.innerHTML.indexOf('Update') > -1 ||
item.innerHTML.indexOf('Resolve') > -1 ||
item.innerHTML.indexOf('Cancel') > -1 ||
item.innerHTML.indexOf('Save') > -1 ||
item.innerHTML.indexOf('Send Email') > -1 ||
item.innerHTML.indexOf('MI Declared') > -1) {
item.hide();
}
});
}catch(e){
jslog('error in DOM manipulation:' + e);
}
}
} else {
//hide the Send Email UI action
var items2 = $$('BUTTON').each(function(item2){
if(item2.innerHTML.indexOf('Send Email') > -1 || item2.innerHTML.indexOf('MI Declared') > -1 ) {
item2.hide();
}
});
}
}
running Client Script : TypeError: $ is not a function.Below is the Client script for this error
function onChange(control, oldValue, newValue, isLoading) {
var callerLabel = $('label.incident.caller_id');
var callerField = $('sys_display.incident.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.incident.caller_id').down('label');
var callerField = $('sys_display.incident.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: ""});
}
}
Please help me out.
Thanks
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2018 04:16 AM
var view = g_form.getParameter('view'); what is the value your getting here ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2018 04:23 AM
Value of view = major_incidents
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2018 03:38 AM
Hi team,
First i got same error when i use $ for catalog client script at "service portal".
so as suggested in the article below, i have updated the code but still am facing issue
https://docs.servicenow.com/bundle/london-servicenow-platform/page/build/service-portal/concept/unsupported_client_scripts.html
please help me with this issue

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2020 10:45 AM
On you client script un-check Isolate script. You may need to add this to the form layout but DOM manipulation will not work if that is checked which it is by default.