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.

I am trying to create a background script for closing a change, for which workflow has broken

sunthosh
Tera Contributor

Hello

I am trying to create a background script for closing a change, for which workflow has broken. Advise on it please.

function getUserRegion() {

  var u = gs.getnumber();

  var gr = new GlideRecord('change_request');

  gr.addQuery('CHG00046',u);

  gr.query();

  while (gr.next()) {

          gr.u_stage= 7;

          gr.update();

  }      

1 ACCEPTED SOLUTION

If you need to change the state, then update the script to use the state field instead.



var gr = new GlideRecord('change_request');


    if (gr.get('number', 'CHG00046')) {


          gr.state= 7;


          gr.update();


View solution in original post

14 REPLIES 14

If you need to change the state, then update the script to use the state field instead.



var gr = new GlideRecord('change_request');


    if (gr.get('number', 'CHG00046')) {


          gr.state= 7;


          gr.update();


Thanks for the perfect code, i found my closed state was 3. The code did other magic's


You are welcome.



If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.



If you are viewing this from the community inbox you will not see the correct answer button.   If so, please review How to Mark Answers Correct From Inbox View.



Thank you


Hi Hari,



Don't forget to click the "Correct Answer" so we can close out this thread. Thank you.


sunthosh
Tera Contributor

Its done thanks, for all the help.