- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2020 08:26 PM
I'm using the following code in a UI Policy to add a gold background color to my Contact field on my case form, when a certain value (TRUE) is set on a field in the Contact table. This is working successfully. However, I'd like to add an icon instead of a background color. How would I change ctrl.style.backgroundColor = 'gold'; to use an icon instead?
images/icons/flag_red.gif
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2020 09:25 PM
I would use the built-in "addDecoration" function. Here's an example from an onChange Client Script we use:
//remove any existing decoration
g_form.removeDecoration("status", "icon-stop-watch", "Status", "color-orange");
g_form.removeDecoration("status", "icon-error-circle", "Status", "color-red");
g_form.removeDecoration("status", "icon-success-circle", "Status", "color-green");
var color = "";
var icon = "";
switch (newValue) {
case "80":
case "100":
color = "color-orange";
icon = "icon-stop-watch";
break;
case "200":
case "300":
color = "color-red";
icon = "icon-error-circle";
break;
case "1000":
color = "color-green";
icon = "icon-success-circle";
}
if (color) {
g_form.addDecoration("status", icon, "Status", color);
}
We show a different icon/color combination based on the value of a field.
This is how it ends up looking:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2020 08:36 PM
Hi,
Try this line instead.
$j("<img src='images/icons/flag_red.gif'>").insertBefore("span[id='case.contact']");
Thanks,
Dhananjay.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2020 08:45 PM
Hi Dhananjay,
Thanks for the quick reply. Unfortunately, that didn't work.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2020 09:04 PM
Hi,
Can you paste your script here.
Thanks,
Dhananjay.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2020 09:13 PM