- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2015 01:46 AM
Hi All,
the business requires the sla due field to change colour based on SLA Task stage. I have written a business rule that write the planned end time to the sla due field on the incident table.
I now am using field styles to change the colour according to the sla status so P1 = 1 hour, P2 = 2 hours, P3 = 24 hours and P4 = 48 hours.
For P1 the colour starts at Orange and goes to red once breached.
For P2 the colour starts green when there is more than an hour to go, changes to orange with less that an hour to go. but doesn't change to red when breached. i have the same coding as P1 and the same errors are happening with P3 and P4s. Please see attached screenshot for field styles coding. could someone point me in the right direction as to what could be wrong.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2015 03:33 AM
it could be that they are returning different values than needed to compare, you could use gs.dateDiff with the true parameters to return the difference in seconds
GlideSystem Date and Time Functions - ServiceNow Wiki
one example:
gs.dateDiff(current.sla_due,gs.nowDateTime,true) > 2400; //or however many seconds you wish to count
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2015 03:33 AM
it could be that they are returning different values than needed to compare, you could use gs.dateDiff with the true parameters to return the difference in seconds
GlideSystem Date and Time Functions - ServiceNow Wiki
one example:
gs.dateDiff(current.sla_due,gs.nowDateTime,true) > 2400; //or however many seconds you wish to count
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2015 05:09 AM
Hi Mguy, so do I just remove the <=gs.minutesAgoStart (-0) and add
javascript:current.priority == 2 &&gs.dateDiff(current.sla_due,gs.nowDateTime,true) > 2400; //or however many seconds you wish to count
I'm fairly new at scripting the stuff i've learnt i've pulled from other suggeations.
thanks
nicky
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2015 05:13 AM
Hi mguy,
I got it 🙂 thanks for your help it is really appreciated.