- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2023 04:51 AM
I am in need of some help please. When a VIP user creates a Service Request I have it setup that that the users names is Highlighted, when I click into the RITM and SCTask it fails to highlight the name. Attached are some screen grabs and the client script.
I tried with Onchange and Onload as well changing the table to sc_req_item.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2023 02:18 AM
I can see in your ritm form screenshot, the "requested for" field is not local to ritm but its coming from "request" (request.requested_for)
It should be like this,
So you can get the requested for field on ritm using form configuration
OR
If you want to create functionality on "request.requested_for" field then you can use the logic from my previous post where i have done the same for sc_task
here on sc_task, requested_for field is came form ritm
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2025 07:13 AM
@Vishal Birajdar @Ralton Stewart I am trying with request.requested_for but I am not getting the output. Any reason why it could be?
function onChange(control, oldValue, newValue, isLoading) {
console.log('Label: ', $('label.sc_req_item.request.requested_for'));
console.log('Field: ', $('sys_display.sc_req_item.request.requested_for'));
var callerLabel = $('label.sc_req_item.request.requested_for');
var callerField = $('sys_display.sc_req_item.request.requested_for');
if (!callerLabel || !callerField)
return;
if (!newValue) {
callerLabel.setStyle({backgroundImage: ""});
callerField.setStyle({color: ""});
return;
}
g_form.getReference('request.requested_for', vipCallerCallback);
}
function vipCallerCallback(caller) {
console.log("Inside callback. Caller object:", caller);
var callerLabel = $('label.sc_req_item.request.requested_for');
var callerField = $('sys_display.sc_req_item.request.requested_for');
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: ""});
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2025 08:39 AM
Hi @mdraehan903
Can you check if Isolate script option on client script is checked or unchecked.
It should be unchecked.
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2025 08:50 AM
hi @Vishal Birajdar
the isolate script option is unchecked. It seems to only work when requested_for is present in the form layout else the client script doesn't work on request.requested_for. Maybe it could be the field on client script that is selected which only shows as Requested for. Hence, I tried adding requested_for to the form layout and hid it with UI policy, and now the client script runs on request.requested_for. But just wanted to see if it can be done without the need of requested_for being added to form layout and using UI policy.