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

Thanks Scott!


Stefan Baldhof1
Kilo Guru

Hi Cyndi,



the easiest way would be to create an "After Update" Business Rule on CR table with conditions on the states mentioned by you. In the script part of the business rule read all Change Tasks like mentioned by and update them to the appropriate state.



Regards,


Stefan


Thanks Stefan!


HI Cyndi,



were you able to solve your problem? Then please mark your question as "Answered". Otherwise it will unnecessarily still be listed as "Not answered" in the community.



Regards,


Stefan


I'm still testing...so far I am still struggling to get the tasks closed.   Neither of the solutions above worked