- 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
10-11-2023 05:18 AM - edited 10-11-2023 05:39 AM
I have tried on sc_req_item table :
uncheck the "Isolate script" option
onChange of requested for :
function onChange(control, oldValue, newValue, isLoading) {
var callerLabel = $('label.sc_req_item.requested_for');
var callerField = $('sys_display.sc_req_item.requested_for');
if (!callerLabel || !callerField)
return;
if (!newValue) {
callerLabel.setStyle({backgroundImage: ""});
callerField.setStyle({color: ""});
return;
}
g_form.getReference('requested_for', vipCallerCallback);
}
function vipCallerCallback(caller) {
var callerLabel = $('label.sc_req_item.requested_for').down('label');
var callerField = $('sys_display.sc_req_item.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: ""});
}
}
Output :
For opened by : you can use
function onLoad() {
var requested_for = g_form.getValue('request_item.requested_for');
var callerLabel = $('label.sc_task.request_item.requested_for');
var callerField = $('sys_display.sc_task.request_item.requested_for');
//alert("Label=" + callerLabel);
// alert("Field=" + callerField);
if (!callerLabel || !callerField)
return;
if (!requested_for) {
callerLabel.setStyle({
backgroundImage: ""
});
callerField.setStyle({
color: ""
});
return;
}
g_form.getReference('request_item.requested_for', vipCallerCallback);
}
function vipCallerCallback(caller) {
//alert('inside vipCaller');
var callerLabel = $('label.sc_task.request_item.requested_for').down('label');
var callerField = $('sys_display.sc_task.request_item.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: ""
});
}
}
Output :
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
11-10-2023 01:49 AM
@Vishal Birajdar I think it's user error on my part but I am not able to highlight requested for are you able to talk me through the steps please?
- 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
10-11-2023 06:13 AM
@Vishal Birajdar thanks for this allow me some time to have a play and I will reach back out. It is much appreciated