Adding style to Incident Number in list view when follow up time is within next one hour.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2025 04:51 AM
Hello folks,
We got a requirement of highlighting (adding '!' icon similar to 'vip' icon) Incident Number in list view if:
The time on 'Follow up' field is within one hour from current hour.
I created a field style in 'sys_ui_style' and have tried every possible code/logic. Yet nothing helps adding the icon to Incident Number in list view.
Any lead/help would be much appreciated.
Thanks in advance,
Juilee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2025 05:11 AM
your field style script should be like this with script include
var DateUtils = Class.create();
DateUtils.prototype = {
initialize: function() {},
checkTime: function(follow_up) {
var followUpTime = new GlideDateTime(follow_up); // Assuming 'follow_up' is the field name
var currentTime = new GlideDateTime();
var oneHourBefore = new GlideDateTime(currentTime);
oneHourBefore.addHours(-1);
var oneHourAfter = new GlideDateTime(currentTime);
oneHourAfter.addHours(1);
var isWithinOneHour = followUpTime >= oneHourBefore && followUpTime <= oneHourAfter;
return isWithinOneHour;
},
type: 'DateUtils'
};
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2025 09:13 AM
Thanks for your reply but unfortunately that's not working either.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2025 10:00 AM
that was just sample
did you debug if you script include is called with correct values?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2025 06:02 AM
Yes @Ankur Bawiskar
I did update the script include as per the requirement.