Saurabh Gupta
Kilo Patron

Hi,
I think schedule job is the right approach.

 

autoclose();

function autoclose() {	
    var gr = new GlideRecord('your_case_table');
    gr.addEncodedQuery('Your_query_means_resolved_case');
	gr.query();
    while (gr.next()) {
        var firstDT = gr.resolved_at;
        var scheduleID = gs.getProperty('24*5_Schedule');//You can change this with a sys_id of 24*5 schedule
        var cdate = gs.nowDateTime();
        var dc = new DurationCalculator();
        dc.setSchedule(scheduleID);
        var diff = dc.calcScheduleDuration(firstDT, cdate);
        //gs.info("amu:"+diff+gr.number);
        if(diff > 864000) //10 days==864000 seconds 
		{
            
            gr.state = 3;//You can check your close value
            gr.active = false;
            gr.comments = 'Case automatically closed after 10 business days in the Resolved state';
            gr.update();
        }
    }
}

 

 


Thanks and Regards,

Saurabh Gupta

Thanks a lot Saurabh!! I think this is what I was looking for, I'll try it out.

Regards

Saurabh Gupta
Kilo Patron

Hi,
You can change the query condition, table and schedule sys_id as per your need.

 

 

 


Thanks and Regards,

Saurabh Gupta

Hi again Saurabh, for some reason the scheduled job did nothing when I ran it, I have tested it in the test environment, I have used the following  

var gr = new GlideRecord(TableName);
gr.addEncodedQuery(state, 6);

then I right click next to the scheduled job name then Copy Sys_ID.

var scheduleID = gs.getProperty('scheduledJobSys_ID')

and for gr.state = 3; I have used the same value since I have it the same, please let me know if there is anything else I need to do to make it work. Thanks

Hi Saurabh, sorry for that but I'm still struggling with the scheduled job and the scheduleID I'm not sure what I should use here, I have used the sys_id for the scheduled job i have created but this seems not the right thing I have to use since when I execute the job it do nothing, so I'm wondering if the scheduled job all what I should do here? and if yes what should I use for gs.getproperty? 

Thanks

Alaa