Changing Field Style for Problem Tasks if due date is passed

Joe Taylor
Giga Guru

I'm trying to change the font color of the due dates in the list view of PTASKS if the due date is past, but no matter what I try it doesn't seem to work.

Here's what I have now:

Table: Problem Task [problem_task]

Field Name: Due date

Value: javascript:gs.dateDiff(current.due_date.getDisplayValue(),gs.nowDateTime(),true) <  0 ;

Style:  color:red;

What am I doing wrong?

Also, where can if find a comprehensive list of styles  (colors, background, font sizes, etc.) ?

 

 

1 ACCEPTED SOLUTION

If its exceeding the field limits then you can put the code in script include and from there return true/false.

Like for yellow you could do this.

1) Create a script include (I named mine as TestDate)
find_real_file.png

 

2) Then call the script include (and function - which I named isYellow) from Styles
find_real_file.png

 

Could you please mark my answer as correct? It gives me few points on community.

Thank you!

 

-Tanaji

Please mark reply correct/helpful if applicable

View solution in original post

21 REPLIES 21

Open is the label and not backed value. Put backed value in value field (should be number value) and try.

-Tanaji
Please mark response correct/helpful if applicable

Joe Taylor
Giga Guru

Ah - Very good!  This is now the behavior I'm looking for.

When I set the state value to '1' instead of 'open', the state field shows up red in the list view now and not the form view.

 

However, this just solved my experiment only.

 

I'm still looking for an answer to my original question which is why my javascript for determining if a PTASK is overdue isn't working.

I've tried 3 different things:

 

   javascript:gs.dateDiff(current.due_date.getDisplayValue(),gs.nowDateTime(),true) < 0 ;

   javascript: var answer =    gs.dateDiff(current.due_date.getDisplayValue(),gs.nowDateTime(),true) < 0; answer;


   javascript: var answer = (current.due_date.getDisplayValue() <= (new   GlideDateTime().getDisplayValueInternal())); answer;

 

None of these work.

Joe Taylor
Giga Guru

So right now this is working on the list view if I'm actually in the Problem ticket itself.

(See 2nd screenshot)

 

Table: Problem Task

Field Name: Due Date

Value:javascript: var answer = (current.due_date.getDisplayValue() <= (new GlideDateTime().getDisplayValueInternal())); answer;

Style: background-color: red

 

However, I'd like this format to show up when I'm in the "Tasks" List view as well.

(1st Screenshot)

find_real_file.png

find_real_file.png

You’d need to add the same field style to the task table and include current.sys_class_name == ‘problem_task’

Joe Taylor
Giga Guru

Where do I include this?  In the Value window?  Like this?

 

 javascript: var answer = (current.due_date.getDisplayValue() <= (new GlideDateTime().getDisplayValueInternal())); answer; current.sys_class_name == 'problem_task';