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
‎06-30-2011 03:28 AM
Hi,
Can any one share the style code. How to change field's color ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2016 11:57 AM
assuming it's a table then u can use below for cell color. template.print("");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2019 09:17 AM
Hlo,
In the style field, you have to write like - background-color:red; or any other color name you want to display.
Code in the Value field can be like this-
javascript: gs.dateDiff(current.opened_at.getDisplayValue(), gs.now().getDisplayValue(), true) < 15000;
Method is - javascript: gs.dateDiff(String startDate, String endDate, Boolean numericValue);
This method expects the earlier date as the first parameter and the later date as the second parameter; otherwise, the method returns the difference as a negative value. Use getDisplayValue() to convert the strings to the expected format.
Here, Earlier date = current.opened_at.getDisplayValue() AND later date is gs.now().getDisplayValue()
Regards,
Shubham