- 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-11-2018 06:46 AM
Bump for help.
- 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
10-05-2023 04:26 AM
Facing same issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2021 09:22 PM
Hello, folks. Am I doing something wrong, or can COLORED decorations not subsequently be removed with "removeDecoration"???
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
var sDecorationMessage = "To save a Problem record, either 'Service' OR 'Configuration Item' must be filled out.";
if (! g_form.getValue("cmdb_ci") && !g_form.getValue("business_service")){
//g_form.addDecoration("cmdb_ci", "icon-star", sDecorationMessage, "color-blue"); //It seems like docorations with COLORS can't later be removed.
//g_form.addDecoration("business_service", "icon-star", sDecorationMessage, "color-blue"); //Can't later be removed.
g_form.addDecoration("cmdb_ci", "icon-star", sDecorationMessage); //Works
g_form.addDecoration("business_service", "icon-star", sDecorationMessage); //Works
}
else
{
g_form.removeDecoration("cmdb_ci", "icon-star", sDecorationMessage);
g_form.removeDecoration("business_service", "icon-star", sDecorationMessage);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2022 01:30 PM
The color parameter can be used for example the following works for me:
g_form.removeDecoration('caller_id', 'icon-accessibility', 'User Sentiment - Red Unhappy, Amber Neutral, Green Happy. This is calculated from surveys taken over time','color-red');
This undoes
g_form.addDecoration('u_actual_sent_overall', 'icon-accessibility', 'User Sentiment - Red Unhappy, Amber Neutral, Green Happy. This is calculated from surveys taken over time', 'color-red');
:
Regards
Paul
