How to add "timer/stopwatch" for Events.

Arjun Reddy Yer
Tera Guru

find_real_file.png

How Timer/Stopwatch can be added to the form so that when user open the ticket can able to see the remaining time for the ticket so that user can solve the ticket.

When User clicks on Publish button then Timer/Stopwatch needs to start.

Note: SLA's are not there can't configure

1 ACCEPTED SOLUTION

Hi,

Create a onDisplay BR on your table. and in the script add this code.

i assume Time left is a duration field. 

(function executeRule(current, previous /*null when async*/ ) {
    var gdt = new GlideDateTime(current.im_notification); //put right field name
    var gdt1 = new GlideDateTime(current.next_update_due); //put right field name
    var dur = new GlideDuration();
    dur = GlideDateTime.subtract(gdt, gdt1); //the difference between gdt1 and gdt2
    current.u_time_left.setValue(dur); //put right field name.
})(current, previous);

Mark the comment as a correct answer and also helpful if this helps to solve the problem.

View solution in original post

17 REPLIES 17

find_real_file.png

Two fields (IM Notification & Next Update Due) needs to compare and then decreasing time like (45 mins) needs to display in decreasing format in Time Left field.

Next Update Due field time is set based on IM Notification field.

Hi,

Create a onDisplay BR on your table. and in the script add this code.

i assume Time left is a duration field. 

(function executeRule(current, previous /*null when async*/ ) {
    var gdt = new GlideDateTime(current.im_notification); //put right field name
    var gdt1 = new GlideDateTime(current.next_update_due); //put right field name
    var dur = new GlideDuration();
    dur = GlideDateTime.subtract(gdt, gdt1); //the difference between gdt1 and gdt2
    current.u_time_left.setValue(dur); //put right field name.
})(current, previous);

Mark the comment as a correct answer and also helpful if this helps to solve the problem.

thanks will check and will let you know if it's working or not

find_real_file.png

it is calculating hours as it should only display 45 mins in decreasing format as the severity is 2 so for severity 2 it should display only 45 mins in decreasing format in Time Left field

In the Br, you can add a check and based on severity, you cna mention the required time.

Let me know if you need any help here. Also if severity is 2.. you have to exclude hours always? how many such conditions are there? y