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.

parent incident should not close when child incident is open

sunnysunny
Kilo Contributor

The requirement is that when we try to close the parent incident while child incidents is open, we should not be able to do that. I wrote BR,before update, but it doesnot work,

please help

(function executeRule(current, previous /*null when async*/) {

  var gr = new GlideRecord('incident');

  gr.addQuery('active',true);

  gr.addQuery('parent',current.sys_id);

  gr.query();

  while(gr.next())

  {

  gr.setAbortAction(true);

  }

})(current, previous);

1 ACCEPTED SOLUTION

nope, last row is wrong in your script, sorry missed that.. it should be current.setAbortAction(true); you have gr.setAbortAction(true);


View solution in original post

6 REPLIES 6

nope, last row is wrong in your script, sorry missed that.. it should be current.setAbortAction(true); you have gr.setAbortAction(true);


Thanks, it works.


Can you help me to understand this code and let   me know if I am wrong.


var gr = new GlideRecord('incident');// in this line we point to the incident table


  gr.addQuery('active',true);//here we added the query to select only the records in which active=true


  gr.addQuery('parent',current.sys_id);// what happens here?


  gr.query();// we execute the query


  while(gr.next())//while loop and we point to the next record


  {


  gr.setAbortAction(true);//we stop the current action


  }



Please correct me if I am wrong