- 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
06-27-2025 12:00 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2025 07:17 PM
Hi @Abbottronix ,
you script works I have tried it on the opened_by field on the sc_task table
just make the isolate script field false on the client script record
Thanks for marking my response as helpful
if you find it helpful and your issue is resolved, could you please mark it as a solution and close the thread as it would help the future readers
Regards
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2025 07:31 PM
That almost fixed everything, only remaining problem is that the text is showing like this:
When it should be showing up red like this:
- 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