how to close sctask records using fix scripts

Vinod S Patil
Tera Contributor

Hello Everyone

I need to close  sctask records which are created at OR before 2025 -05-23 and in progress state
Please help with fix script.


Regards
Vinod

2 ACCEPTED SOLUTIONS

swathisarang98
Giga Sage
Giga Sage

Hi @Vinod S Patil ,

 

I have tried the below code in my pdi please do give it a try,

 

var gr = new GlideRecord('sc_task');
gr.addQuery('state','1');//Open state
gr.addEncodedQuery("sys_created_on<=javascript&colon;gs.dateGenerate('2023-05-23','23:59:59')");
gr.query();
while (gr.next()) {
    gr.state = '3';
    gr.update();
    //gs.print('Number : ' + gr.number);
}

 

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang

View solution in original post

var scTask = new GlideRecord('sc_task');
scTask.addEncodedQuery('state=2^sys_created_on<=javascript&colon;gs.dateGenerate('2021-05-23','23:59:59')');
scTask.query();
while(scTask.next(){
scTask.setValue('state',3);
scTask.update();
}

Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

View solution in original post

4 REPLIES 4

Mark Manders
Mega Patron

What did you already try? And looking at your query: that's all in progress state sc_task, right?


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

var gr = new GlideRecord('sc_task');

gr.addEncodedQuery('stateIN1,2^sys_created_on<javascript&colon; gs.dateGenerate('2021-05-23')');

gr.setLimit(5);
gr.query();

while(gr.next){

 

gr.state = 3;

gr.update();

}

@Mark Manders 

var scTask = new GlideRecord('sc_task');
scTask.addEncodedQuery('state=2^sys_created_on<=javascript&colon;gs.dateGenerate('2021-05-23','23:59:59')');
scTask.query();
while(scTask.next(){
scTask.setValue('state',3);
scTask.update();
}

Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

swathisarang98
Giga Sage
Giga Sage

Hi @Vinod S Patil ,

 

I have tried the below code in my pdi please do give it a try,

 

var gr = new GlideRecord('sc_task');
gr.addQuery('state','1');//Open state
gr.addEncodedQuery("sys_created_on<=javascript&colon;gs.dateGenerate('2023-05-23','23:59:59')");
gr.query();
while (gr.next()) {
    gr.state = '3';
    gr.update();
    //gs.print('Number : ' + gr.number);
}

 

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang