Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

Auto Close Change Request from review state

Delapan
Tera Contributor

Hello,

I want to auto close the change from review state, when all its associated tasks are closed.
How can I achieve this??

Thanks in advance!!

2 REPLIES 2

Ankur Bawiskar
Tera Patron

@Delapan 

you can use after update BR on change task and handle this.

Check if all Change tasks for this CHG are closed or not and then close CHG

what did you start and where are you stuck?

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar 

(function executeRule(current, previous /*null when async*/) {

    var ctask = new GlideRecord('change_task');
    ctask.addEncodedQuery('state=3^change_request='+current.change_request);
    ctask.query();
    if (!ctask.next())
    {
        var change = new GlideRecord('change_request');
        change.addQuery('sys_id', current.change_request);
        change.query();
        if (change.next())
        {
            change.state = 3;
            change.update();
        }
    }

})(current, previous);