- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2022 03:24 PM
I'm trying to add a VIP flag (similar to the OOB flag on incident caller) to the "opened for" field on interactions. I'm trying to repurpose the same client script from incident (see below), but am receiving this error "onChange script error: TypeError: $ is not a function function () { [native code] }". Please let me know if there is a better way to go about doing this or any changes you would recommend to my script below, thank you in advance!
function onChange(control, oldValue, newValue, isLoading) {
var callerLabel = $('label.interaction.opened_for');
var callerField = $('sys_display.interaction.opened_for');
if (!callerLabel || !callerField)
return;
if (!newValue) {
callerLabel.setStyle({backgroundImage: ""});
callerField.setStyle({color: ""});
return;
}
g_form.getReference('opened_for', vipCallerCallback);
}
function vipCallerCallback(caller) {
var callerLabel = $('label.interaction.opened_for').down('label');
var callerField = $('sys_display.interaction.opened_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: ""});
}
}
Solved! Go to Solution.
- Labels:
-
Agent Workspace

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2022 04:13 PM
Hello marrerocmm,
Try to run this code:
function onChange(control, oldValue, newValue, isLoading) {
var callerLabel = $('label.interaction.opened_for');
var callerField = $('sys_display.interaction.opened_for');
if (!callerLabel || !callerField)
return;
g_form.getReference('opened_for', vipCallerCallbackINT);
}
function vipCallerCallbackINT(caller) {
var callerLabel = $('label.interaction.opened_for').down('label');
var callerField = $('sys_display.interaction.opened_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'
});
//set callerField color
callerField.setStyle({
color: "red"
});
} else {
callerLabel.setStyle({
backgroundImage: ""
});
callerField.setStyle({
color: ""
});
}
}
Please mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!
Best Regards,
Filipe Cruz

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2022 03:38 PM
Hello,
At least this code will not work:
var callerLabel = $('label.interaction.opened_for');
var callerField = $('sys_display.interaction.opened_for');
Try to replace by:
var callerLabel = g_form.getValue('label.interaction.opened_for');
var callerField = g_form.getValue('sys_display.interaction.opened_for');
Please mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!
Best Regards,
Filipe Cruz
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2022 03:44 PM
Thanks so much for your response Filipe! The script isn't generating an error anymore, but it isn't showing the VIP flag either. Here is the updated script:
function onChange(control, oldValue, newValue, isLoading) {
var callerLabel = g_form.getValue('label.interaction.opened_for');
var callerField = g_form.getValue('sys_display.interaction.opened_for');
if (!callerLabel || !callerField)
return;
if (!newValue) {
callerLabel.setStyle({backgroundImage: ""});
callerField.setStyle({color: ""});
return;
}
g_form.getReference('opened_for', vipCallerCallback);
}
function vipCallerCallback(caller) {
var callerLabel = $('label.interaction.opened_for').down('label');
var callerField = $('sys_display.interaction.opened_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
‎04-04-2022 04:13 PM
Hello marrerocmm,
Try to run this code:
function onChange(control, oldValue, newValue, isLoading) {
var callerLabel = $('label.interaction.opened_for');
var callerField = $('sys_display.interaction.opened_for');
if (!callerLabel || !callerField)
return;
g_form.getReference('opened_for', vipCallerCallbackINT);
}
function vipCallerCallbackINT(caller) {
var callerLabel = $('label.interaction.opened_for').down('label');
var callerField = $('sys_display.interaction.opened_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'
});
//set callerField color
callerField.setStyle({
color: "red"
});
} else {
callerLabel.setStyle({
backgroundImage: ""
});
callerField.setStyle({
color: ""
});
}
}
Please mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!
Best Regards,
Filipe Cruz
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2022 06:00 AM
Thank you Filipe! That worked! I did have to add the "isolate script" checkbox to the client script form and uncheck it, but once I did that the script worked. Thank you very much for your help!