Onload script error:- TypeError: $ is not a function
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2025 08:07 AM
Hi,
There is onload script that is giving error on portal as "TypeError: $ is not a function". I have marked the isolate script false but still getting the same error.
Here is the code for you:-
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2025 08:08 AM
the client script looks similar to client script on User table for caller
the above client script is on which table?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2025 08:12 AM
Its on Requested Item [sc_req_item] table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2025 09:10 PM
is requested_for field on RITM form or not?
what debugging did you perform?
code is running till which line?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2025 05:53 AM
Hello @ChanchalG ,
There's a lot going on in that script that is against ServiceNow best practices, e.g. DOM manipulation and usage of g_form.getReference().
It seems you want to highlight the "Requested for" user field when the selected user is a VIP. Please consider the following alternative approach:
Step 1: create a Business Rule
- Table: sc_req_item
- Advanced: true
- When: display
- Script:
(function executeRule(current, previous /*null when async*/) {
g_scratchpad.vip = current.requested_for.vip.toString() === 'true';
})(current, previous);
Step 2: remove all code from your Client Script and replace it with this:
function onLoad() {
if (g_scratchpad.vip) {
g_form.addDecoration('requested_for', 'icon-star', 'VIP', 'color-red');
}
}
Result:
Regards,
Robert