Change colour of field style based on date comparison
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2009 08:48 AM
Hi
I'm trying to get the due date field text on the Problem form to change colour if the date is in the past.
I've created a field style for the field 'Due Date' on the Problem table to turn read if the following value is true:
javascript:gs.dateDiff(gs.nowDateTime(), current.due_date, true) < 0
However, this changes the colour for that field on every record whether or not it is in the past. Has anyone done something similar or can you see a glaring error in the comparison code above?
Thanks in advance,
Andrew
P.S. Our date format here is dd/MM/yyyy HH:mm:ss
- Labels:
-
Problem Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2009 07:24 AM
OK, I think I've cracked it.
javascript:gs.dateDiff(current.due_date,gs.nowDateTime(),true) > 0 ;
wasn't working because gs.nowDateTime() returns the current date/time in the user defined format but current.due_date is in a different date format
javascript:gs.dateDiff(current.due_date.getDisplayValue(),gs.nowDateTime(),true) > 0 ;
works as it returns current.due_date in the user defined format.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2011 01:18 PM
This works great, but changes color for all tickets. I would like to exclude tickets that are not active. Any ideas?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2010 07:39 AM
Hello Folks
I'm running into the same kind of issue and cannot find the right syntax to achie what I want.
Based on what is explained above, I'm trying to highlight requested items that have been updated within the 5 last days, so I created the following style:
Table: task
Fieldname: sys_updated _on
Value: javascript:gs.dateDiff(current.sys_updated_on.getDisplayValue(), gs.nowDateTime(), true) < 6
Style: background-color:tomato
Where did I do wrong ?
Christian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2010 10:08 AM
Code looks fine but dateDiff returns number of seconds so you'll need to increase the value of your check.