How can i restrict Change task closure until the change request state is set to scheduled?

Sofiya Perumal
Tera Expert

Hi Experts,

 

I have to restrict change task closure if the change state until it reached to schedule.

 

Could you please help me with the above requirement.

 

Regards,

Sofiya

2 REPLIES 2

Nishant8
Giga Sage

Hello @Sofiya Perumal, you can write a BR against table: 'change_task' to achieve the same. In the When to Run section, ensure it runs on Closed and Cancelled (you can change accordingly) state; in the advanced you can write a script to do the job, something like below (please verify the Scheduled state corresponding number, I believe its -2)

(function executeRule(current, previous /*null when async*/ ) {
    var changeGR = new GlideRecord('change_request');
    changeGR.get(current.change_request);
    if (changeGR.state < -2) {
        gs.addErrorMessage("Change is not yet moved to Scheduled state");
        current.setAbortAction(true);
    }

})(current, previous);
 
Regards,
Nishant

Runjay Patel
Giga Sage

Hi @Sofiya Perumal ,

 

Configure BR on change task table like below. I have tested it, working fine.

RunjayPatel_0-1732083136460.png

RunjayPatel_1-1732083191564.png

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------