Background Script - Change State

ToniOxley
Kilo Expert

Good Morning,

 

Please can someone advise... i need a background script to force two CHG records to the state Implement. We have discovered a fault within the change workflow and whilst we get that sorted.. we need to manually force a couple of changes to "implement" so we can proceed with them.

Advise/the script we need to run... would be much appreciated.

find_real_file.png

As you can see.. i am unable to change the state from the list view (or the form view)

find_real_file.png

thanks again!

1 ACCEPTED SOLUTION

Suseela Peddise
Kilo Sage

Hi,

As per OOB normal change state model , change can we move from authorize to schedule/cancel states only. .

See 'ChangeRequestStateModel_normal' script include.

So, you need use setWorkflow to false before running the script in backgroud or else business rule will stop doing that. Try below script:

var gr= new GlideRecord('change_request');
gr.addEncodedQuery("numberINCHG0030712,CHG0030714");

gr.query();

while(gr.next()){

gr.setWorkflow(false); //prevent running business rule
gr.state='-1';//implement state
gr.update();

}

 

Hope this helps!

If I have answered your question, please mark my response as correct and/or helpful.

Thanks,

Suseela P.

View solution in original post

5 REPLIES 5

Ankur Bawiskar
Tera Patron

@ToniOxley 

Glad that you got the approach.

Did you mistakenly mark other answer as correct?

As I see same/similar script was provided before from my end.

Please mark appropriate reply as correct and helpful to help others with the same response find the answer more quickly.

Regards
Ankur