- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2024 05:51 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2024 06:26 AM
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: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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2024 06:26 AM
var scTask = new GlideRecord('sc_task');
scTask.addEncodedQuery('state=2^sys_created_on<=javascript: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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2024 06:03 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2024 06:13 AM
var gr = new GlideRecord('sc_task');
gr.addEncodedQuery('stateIN1,2^sys_created_on<javascript: gs.dateGenerate('2021-05-23')');
gr.setLimit(5);
gr.query();
while(gr.next){
gr.state = 3;
gr.update();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2024 06:26 AM
var scTask = new GlideRecord('sc_task');
scTask.addEncodedQuery('state=2^sys_created_on<=javascript: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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2024 06:26 AM
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: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