colour coding for a field based on SLA breaching timing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2024 02:14 AM
Hi Community
I have a requirement to populate the SLA Original breach time but it should also follow the color code to the field. populating the data have been configured , but need help in how to make an automated way to make the filed color changes as per the SLA breach timing.
could you please help me how can i configure color coding to Fileds.
- Labels:
-
ITSM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2024 03:32 AM
You can use field styles for this: https://docs.servicenow.com/bundle/washingtondc-platform-administration/page/administer/navigation-a...
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2025 01:10 AM
Write an onchange client script
(function executeRule(current, gForm, gSNC) {
var breachTime = current.getValue('u_original_breach_time');
var now = new Date();
var breachDate = new Date(breachTime);
if (breachTime) {
var diff = (breachDate - now) / (1000 * 60 * 60);
if (diff < 0) {
gForm.setStyle('u_original_breach_time', 'color', 'red');
} else if (diff <= 2) {
gForm.setStyle('u_original_breach_time', 'color', 'orange');
} else {
gForm.setStyle('u_original_breach_time', 'color', 'green');
}
}
})(current, gForm, gSNC);
write the field values as per your form.