Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Help with change request

Abhijit Das7
Tera Expert

Hi Everyone,

 

I am working on change request; the state of change request should not change to "Closed" if any of its change task are in open condition.

 

Basically, I should be able to close change request if all the change tasks attached to it are in closed state.

 

please provide some suggestions.

 

Thanks in advance.

1 ACCEPTED SOLUTION

Harish KM
Kilo Patron
Kilo Patron

Hi @Abhijit Das7 Create a before update BR on change_request table

Condition: state changesTO complete

script:

    var chgTask = new GlideRecord('change_task');
    chgTask.addQuery('change_request', current.sys_id);
    chgTask.addEncodedQuery('stateIN-5,1,2'); //OPEN,PENDING,WIP
    chgTask.query();
    while (chgTask.next()) {
        gs.addErrorMessage("Change Task are active" + chgTask.getValue('number'));
        current.setAbortAction(true);
    }
Regards
Harish

View solution in original post

1 REPLY 1

Harish KM
Kilo Patron
Kilo Patron

Hi @Abhijit Das7 Create a before update BR on change_request table

Condition: state changesTO complete

script:

    var chgTask = new GlideRecord('change_task');
    chgTask.addQuery('change_request', current.sys_id);
    chgTask.addEncodedQuery('stateIN-5,1,2'); //OPEN,PENDING,WIP
    chgTask.query();
    while (chgTask.next()) {
        gs.addErrorMessage("Change Task are active" + chgTask.getValue('number'));
        current.setAbortAction(true);
    }
Regards
Harish