updating sc task state when the variable date matches with current date

Rahul Raja Sami
Tera Guru

Hi 

this is my script

 

var gr = new GlideRecord('sc_task');
gr.addQuery('number', 'NUMBER');
gr.query();
if (gr.next()) {
var today = new GlideDate();
today.setDisplayValue('yyyy-MM-dd');
if (gr.variables.termination_date == today.getValue()) {
gr.setValue('state', '2');
gr.update();
}
}

 

I am not sure why this is not working?

and one more question which type of BR suits the best for my condition?

1 ACCEPTED SOLUTION

Working fine amit,

just the format missed, I have corrected it and working now.

View solution in original post

5 REPLIES 5

When I using the schedule job with date diff calculation.

If current date is greater than current date I mean diff <0 then need to change the sctask state to in progress

 

But state is not changing

IMG20250226080059.jpg