how to change the backgroud color of filed

RyotaroT
Tera Contributor

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&colon;(current.u_activity_id == 1 && current.u_response_target_date != null && current.u_response_target_date < new global.RecordUtil().getLocalDate())

javascript&colon;(current.u_activity_id == 1 && current.u_response_target_date != null && current.u_response_target_date.toString() < new global.RecordUtil().getLocalDate().toString())

javascript&colon;(current.u_activity_id == 1 && current.u_response_target_date != null && new GlideDateTime(current.u_response_target_date).getValue() < new GlideDateTime().getValue())

1 REPLY 1

James Chun
Kilo Patron

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.

JamesChun_0-1748317244465.png

 

In regards to your script, try the following to

javascript&colon; (current.u_activity_id == 1 && current.u_response_target_date != null && gs.dateDiff(gs.now(), current.u_response_target_date.getDisplayValue(), true) < 0)

 

Cheers