Auto Cancel Change Task when Change Request transitioned to Closed Incomplete

cjones3
Tera Contributor

I need some assistance in auto-canceling or closing related CTASK items when the CHG is moved to closed incomplete or canceled state.   My current UI Action on the change will close the change request, but the underlying task is remaining open in the fulfiller's work queue.   Thoughts?

1 ACCEPTED SOLUTION

Aakash Shah4
Tera Guru

HI Cyndi,



You will have to write a Business rule to achieve this


Table : Change_request


Type : After


Insert : true


Update : true



Conditions : current.state == 7 && current.state.changes()       // place your values of state accordingly



Script :



abortKids();


function abortKids() {


  if (current.sys_id == '')


        return;




  var kids = new GlideRecord('change_task');


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


  kids.query();


  while (kids.next()) {


      if (kids.active == true) {


      kids.state = 7;


      kids.update();


      }


  }


}



Note : This can also be achieved using UI action placing the same code. Let me know if you have any issues.


View solution in original post

12 REPLIES 12

Hi Cyndi



When you move the change from review into Close or Cancel, how are you doing it?



Are you using a ui action, if so could you share the detail of it so we can see what the ui action is doing?



Also if you look at the state choices of your ctasks, are 3,4,7 closed states?



And as a check what is the state choice value for close and cancel on your change table?


Aakash Shah4
Tera Guru

HI Cyndi,



You will have to write a Business rule to achieve this


Table : Change_request


Type : After


Insert : true


Update : true



Conditions : current.state == 7 && current.state.changes()       // place your values of state accordingly



Script :



abortKids();


function abortKids() {


  if (current.sys_id == '')


        return;




  var kids = new GlideRecord('change_task');


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


  kids.query();


  while (kids.next()) {


      if (kids.active == true) {


      kids.state = 7;


      kids.update();


      }


  }


}



Note : This can also be achieved using UI action placing the same code. Let me know if you have any issues.


Thank you Aakash...that worked beautifully!