Alternative for document and $ in DOM in client script
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2024 12:46 AM
Hi everyone,
I need to replace the all Dom related things from below code( $('label.sc_task.request_item.request.requested_for'), $('sys_display.sc_task.request_item.request.requested_for') and document.documentElement.getAttribute('data-doctype'))
var callerLabel = $('label.sc_task.request_item.request.requested_for').down('label');
var callerField = $('sys_display.sc_task.request_item.request.requested_for');
if (!callerLabel || !callerField)
return;
// Alternative approach using GlideForm API in ServiceNow client script
//check for VIP status
if (answer == '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'
});
//set callerField color
callerField.setStyle({
color: "#FF0000"
});
} else {
callerLabel.setStyle({
backgroundImage: ""
});
callerField.setStyle({
color: ""
});
}
0 REPLIES 0