- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2025 11:52 PM
I'm trying to adapt the OOTB "Highlight VIP Caller" client script to apply to the Requested By (opened_by) and Requested For (request_item.requested_for) fields on the sc_task table. I copied the original script and swapped out the table and fields, but I'm getting this error:
This is the script I'm using for the Requested By (opened_by) field:
function onChange(control, oldValue, newValue, isLoading) {
var callerLabel = $('label.sc_task.opened_by');
var callerField = $('sys_display.sc_task.opened_by');
if (!callerLabel || !callerField)
return;
if (!newValue) {
callerLabel.setStyle({backgroundImage: ""});
callerField.setStyle({color: ""});
return;
}
g_form.getReference('opened_by', vipCallerCallback);
}
function vipCallerCallback(caller) {
var callerLabel = $('label.sc_task.opened_by').down('label');
var callerField = $('sys_display.sc_task.opened_by');
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: ""});
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2025 08:08 PM
HI @Abbottronix ,
if the field is made read-only using UI Policy or client script
update your script like this
function onChange(control, oldValue, newValue, isLoading) {
var callerLabel = $('label.sc_task.opened_by');
var callerField = $('sys_display.sc_task.opened_by');
if (!callerLabel || !callerField)
return;
if (!newValue) {
callerLabel.setStyle({backgroundImage: ""});
callerField.setStyle({color: ""});
return;
}
g_form.getReference('opened_by', vipCallerCallback);
}
function vipCallerCallback(caller) {
var callerLabel = $('label.sc_task.opened_by').down('label');
var callerField = $('sys_display.sc_task.opened_by');
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' });
g_form.setReadOnly('opened_by',false);
callerField.setStyle({color: "red"});
g_form.setReadOnly('opened_by',true);
} else {
callerLabel.setStyle({backgroundImage: ""});
callerField.setStyle({color: ""});
}
}
if the field is made read-only dictionary level (try to make it read-only using UI policy or client script)
if not looks like there is no workaround for adding styles like color for fields which are read-only at the dictionary leve
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
g_form.setReadOnly('opened_by', true);
}
var callerLabel = $('label.sc_task.opened_by');
var callerField = $('sys_display.sc_task.opened_by');
if (!callerLabel || !callerField)
return;
if (!newValue) {
callerLabel.setStyle({
backgroundImage: ""
});
callerField.setStyle({
color: ""
});
return;
}
g_form.getReference('opened_by', vipCallerCallback);
}
function vipCallerCallback(caller) {
var callerLabel = $('label.sc_task.opened_by').down('label');
var callerField = $('sys_display.sc_task.opened_by');
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'
});
g_form.setReadOnly('opened_by', false);
callerField.setStyle({
color: "red"
});
g_form.setReadOnly('opened_by', true);
} else {
callerLabel.setStyle({
backgroundImage: ""
});
callerField.setStyle({
color: ""
});
}
}
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2025 09:24 PM
Perfect! Thank you, you've been so helpful!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2025 01:12 AM
Hi Abbott,
Could you Please try using below:
Instead of: var callerField = $('sys_display.sc_task.opened_by');
Use: var callerField = document.getElementById('sys_display.sc_task.opened_by');
And for the label:var callerLabel = document.querySelector('label[for="sc_task.opened_by"]');
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Pavani P
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2025 07:05 PM
It's now giving me this error