The CreatorCon Call for Content is officially open! Get started here.

when problem ticket closed then related incidents close automatically

divya123
Giga Contributor

when problem ticket closed then related incidents tickets should close automatically, i write below code but that is not working, kindly help me with your suggestions. (function executeRule(current, previous /*null when async*/) { var gr =new GlideRecord('incident'); gr.addQuery('problem_id',current.sys_id); gr.query(); if(gr.next()){ gr.state= '6'; gr.close_code= Solved('Work Around'); gr.close_notes= resolved; gr.update(); } })(current, previous); Thanks

1 ACCEPTED SOLUTION

amlanpal
Kilo Sage

Hi Divya,



You need to create/modify a after Update Business rule in the Problem ('problem') table with the Conditions and script as per below screenshot. I have tested the code and is working in my instance. Would like to request you to give it a try and let me know.


For your simplicity, I'm providing the code here:



(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);



find_real_file.png


find_real_file.png



I hope this helps.Please mark correct/helpful based on impact


View solution in original post

7 REPLIES 7

Use this for your requirement and this will 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();


if (gr.next()) {

if(current.state=='107'){

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);

 

hope it helped you.

Hi Amlanpal,

Only for New State yet I am unable to resolved the incident automatically.

For in progress, assainged its working

VRNR
Kilo Contributor

Hi All,

 I want to close problem task as well (p_task)  which was created for the parent problem.may i know how can i achieve this?

 

Regards,

ram