Auto Close Problem after 7 days

abhijee
Tera Contributor

Hello Experts,

I am seeking guidance on a requirement to close problem tickets that have not had any incidents for 7 days. I attempted to fulfill this requirement using a scheduled job, but unfortunately, my script is not functioning as expected. Could someone please assist me with this? Thank you.

 

var prb=new GlideRecord('problem');
prb.addEncodedQuery('stateNOT IN106,107^related_incidents=0');
prb.setLimit(1);
prb.query();
while(prb.next())
{
prb.state=107;
prb.fix_notes=" test Scheduled Job";
prb.update();

}