- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2018 08:57 AM
What can I use to remove a decoration added via g_form.addDecoration in an onChange Client Script? g_form.removeDecoration isn't available.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2018 01:44 PM
So, turns out removeDecoration takes multiple parameters. I put this on my PDI and tried it out. I updated the removeDecoration to have three parameters;
g_form.removeDecoration('caller_id', 'icon-star', 'VIP');
function onChange(control, oldValue, newValue, isLoading) {
var callerLabel = $('label.incident.caller_id');
var callerField = $('sys_display.incident.caller_id');
if (!callerLabel || !callerField) {
return;
}
if (!newValue) {
callerLabel.setStyle({
backgroundImage: ""
});
callerField.setStyle({
color: ""
});
return;
}
g_form.getReference('caller_id', function(caller) {
var callerLabel = $('label.incident.caller_id').down('label');
var callerField = $('sys_display.incident.caller_id');
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: '5px', color: "#e34234" });
callerLabel.setStyle({
color: "#e34234"
});
callerField.setStyle({
color: "#e34234"
});
g_form.addDecoration('caller_id', 'icon-star', 'VIP');
} else {
callerLabel.setStyle({
backgroundImage: "",
color: ""
});
callerField.setStyle({
color: ""
});
//g_form.removeDecoration('caller_id');
g_form.removeDecoration('caller_id', 'icon-star', 'VIP');
}
});
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2018 09:10 AM
It should be available on both mobile/sp and desktop. Where is it unavailable?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2018 09:27 AM
I think you misread. I changed the VIP Client Script to use addDecoration instead. The problem is that if the Caller is changed to a non-VIP, the icon doesn't disappear.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2018 09:31 AM
Can you share your code? g_form.removeDecoration(...) should be available.
Also so this is on the standard UI or in the service portal?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2018 11:20 AM
Maybe I'm just using it incorrectly?
function onChange(control, oldValue, newValue, isLoading) {
var callerLabel = $('label.incident.caller_id');
var callerField = $('sys_display.incident.caller_id');
if (!callerLabel || !callerField)
return;
if (!newValue) {
callerLabel.setStyle({backgroundImage: ""});
callerField.setStyle({color: ""});
return;
}
g_form.getReference('caller_id', vipCallerCallback);
}
function vipCallerCallback(caller) {
var callerLabel = $('label.incident.caller_id').down('label');
var callerField = $('sys_display.incident.caller_id');
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: '5px', color: "#e34234" });
callerLabel.setStyle({color: "#e34234" });
callerField.setStyle({color: "#e34234"});
g_form.addDecoration('caller_id', 'icon-star', 'VIP');
} else {
callerLabel.setStyle({backgroundImage: "", color: ""});
callerField.setStyle({color: ""});
g_form.removeDecoration('caller_id');
}
}
