Adding style to Incident Number in list view when follow up time is within next one hour.

JuileeD
Tera Contributor

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

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

@JuileeD 

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'
};

AnkurBawiskar_0-1742472627241.png

 

AnkurBawiskar_1-1742472675832.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

JuileeD
Tera Contributor

@Ankur Bawiskar 

Thanks for your reply but unfortunately that's not working either.

@JuileeD 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

JuileeD
Tera Contributor

Yes @Ankur Bawiskar 
I did update the script include as per the requirement.