If a Case is closed or resolved, set all connected Incidents that are not resolved to resolved

ServiceLater1
Giga Contributor

Hi there,

I am trying to achieve the following and unsure how to go about it:

If a Case is closed or resolved, I want all connected Incidents that are not already resolved or closed to be set to state resolved.

What's the best way to achieve this?

1 ACCEPTED SOLUTION

Hey

Create an after Update Business rule.

Here it is shown for problem, similarly you can do for your case table.

Below Code snippet should help:

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

      var gr = new GlideRecord('incident');
      gr.addActiveQuery(); //Cross check only active incidents
      gr.addQuery('problem_id', current.sys_id);
      gr.query();
      while(gr.next()){

              gr.state = '6';
              gr.close_code = 'Solved (Work Around)';
              gr.close_notes = 'The incident is Resolved as the Related Problem is Closed/Resolved';
              gr.update();
      }
      gs.addInfoMessage('The Incident'+ gr.number+' is Resolved');

})(current, previous);

 

Best Regards
Aman Kumar

View solution in original post

3 REPLIES 3

Aman Kumar S
Kilo Patron

Use After business rule for closing related records

Best Regards
Aman Kumar

ServiceLater1
Giga Contributor

Thanks, are there any examples you could point me to?

Hey

Create an after Update Business rule.

Here it is shown for problem, similarly you can do for your case table.

Below Code snippet should help:

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

      var gr = new GlideRecord('incident');
      gr.addActiveQuery(); //Cross check only active incidents
      gr.addQuery('problem_id', current.sys_id);
      gr.query();
      while(gr.next()){

              gr.state = '6';
              gr.close_code = 'Solved (Work Around)';
              gr.close_notes = 'The incident is Resolved as the Related Problem is Closed/Resolved';
              gr.update();
      }
      gs.addInfoMessage('The Incident'+ gr.number+' is Resolved');

})(current, previous);

 

Best Regards
Aman Kumar