how to change the backgroud color of filed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2025 01:22 AM
I want to change the background color of a field depending on a condition.
I know how to do it, but I want to specify a condition that the date entered in a specific field is before today, but I can't get it to work.
i tried these codes but they didnt work
javascript:(current.u_activity_id == 1 && current.u_response_target_date != null && new GlideDateTime(current.u_response_target_date).before(new GlideDateTime()))
javascript:(current.u_activity_id == 1 && current.u_response_target_date != null && current.u_response_target_date < new global.RecordUtil().getLocalDate())
javascript:(current.u_activity_id == 1 && current.u_response_target_date != null && current.u_response_target_date.toString() < new global.RecordUtil().getLocalDate().toString())
javascript:(current.u_activity_id == 1 && current.u_response_target_date != null && new GlideDateTime(current.u_response_target_date).getValue() < new GlideDateTime().getValue())
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2025 08:43 PM
Hi @RyotaroT,
Please note that if you have a condition (i.e. 'Value' field populated in the Style record), the style will only apply on the list OR both list and the form only when the field is read-only.
i.e.
In regards to your script, try the following to
javascript: (current.u_activity_id == 1 && current.u_response_target_date != null && gs.dateDiff(gs.now(), current.u_response_target_date.getDisplayValue(), true) < 0)
Cheers