Autoclose problem ticket if its in resolved state for 14 days

Priyanka77
Tera Guru

Hi,
I need to close the problem ticket if its in resolved state for last 14 days. 

Can someone please guide me to achieve this.

Thanks,
Priyanka

1 ACCEPTED SOLUTION

Priyanka77
Tera Guru

Thanks everyone my script is working now as i have just compared two dates 

View solution in original post

8 REPLIES 8

Samaksh Wani
Giga Sage
Giga Sage

Hello @Priyanka77 

 

You need to create a Flow Designer for that.

 

Where you can select Wait for Condition till 14 Days.

 

to trigger the change.

 

Plz Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.

 

Regards,

Samaksh

Thanks @Samaksh Wani for your response
But instead of creating complete flow can we design this functionality through business rule or schedule job.

Hello @Priyanka77 

 

See Priyanka, The BR will work only when the certain criterial of form met suppose no one have not opened the form or met the criteria after 14 day, it will not get execute.

 

Also for creating a Automatic update the right way is to use Flow Designer.

 

Plz Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.

 

Regards,

Samaksh

Chetan Mahajan
Kilo Sage
Kilo Sage

Hello @Priyanka77 ,

                                   Create schedule job and write below script in that run it on daily basis 

 

updateRecords();

//It would check if the days between Resolved and now time is more than 14 working days i.e. the difference is excluding weekends.
function updateRecords() {  

    try {
        var prbGR= new GlideRecord('problem');
        prbGR.addQuery('state', 6);  // 6 = Resolved  *make changes based on your value
        prbGR.query();
        while (prbGR.next()) {

            var start = new GlideDateTime(prbGR.resolved_at);
            var nowTime = new GlideDateTime();

            var days = getDateDiffExcWeekends(start, nowTime);
            // if days more than 14
            if (days >= 14) {
                prbGR.state = 10;  //closed
                prbGR.active = false;
                prbGR.update();
            }
        }
    } catch (ex) {
        gs.info(ex);
    }
}

 

Kindly mark Correct and Helpful if applicable