- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2024 02:03 AM
Hi community,
I'm trying to set a field style based on a numerical value and wondered if this was even possible.
So I have a custom field on the cmdb_ci_computer called score which will be a number and they way I envision this working is if the value is if the value is...
less than 30 highlight the field red
between 30 - 60 orange
between 60 - 100 green.
Is what I'm trying even possible?
Many thanks,
Alex
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2024 03:12 AM
Hi,
Yes it's possible to include a range.
Modify your value into something like this:
javascript: (current.u_score > 0 && current.u_score < 30)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2024 02:15 AM
Hello @Alex Saager1 ,
There are two ways,
1. Using client script :
var myField = "<your field name>';
var ctrl = g_form.getControl(myField);
if(<your condition>=="<certain value>") {
ctrl.style.backgroundColor = 'red';
ctrl.style.color ='black';
g_form.setVisible('<yourfield>',true);
}
2. System UI > Field Styles.
- Using field styles also you can do.
Thanks,
Valmik Patil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2024 02:47 AM
Thanks for this, is it possible to do a between operator on the value so for example if the number is between 1 and say 10, i tried the below but it didn't work:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2024 03:12 AM
Hi,
Yes it's possible to include a range.
Modify your value into something like this:
javascript: (current.u_score > 0 && current.u_score < 30)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2024 03:27 AM - edited 07-02-2024 03:28 AM
Hi @OlaN
Slightly changed it to:
javascript: (current.u_score > 0 && current.u_score < 30)
But that worked perfectly, thank you 🙂