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.

Need to Change the State to Implement when Start Date is Reached in Change Request

User395771
Tera Contributor

We are Creating a Change from Service Request(RITM), Can we Change the Change Request State to Implement when the Planned Start Date is Reached ?

When Change is Created State is set to Schedule and Change to Implement when Planned Start is Reached.

States Below :

Implement= -1
Scheduled= -2

5 REPLIES 5

Peter de Bock1
Mega Guru

Just implemented this for my current customer. It works fine!

 

Please mark helpfull when it does! thanks

 

Final script I used:

var grCR = new GlideRecord('change_request');
//Active scheduled Changes with a Start date till 1 Hour from now
grCR.addEncodedQuery('active=true^state=-2^start_date<=javascript:gs.hoursAgo(-1)'); 
grCR.query();
while (grCR.next()) {
    grCR.state = -1; //Implement state
    grCR.update();
    gs.log('Automatically move scheduled Change ' + grCR.number + ' to Implement as it almost reaches Planned start', 'Scheduled script: move scheduled Changes to Implement');
}

Scheduled script Execution:

find_real_file.png

Regards, Peter