Closing all task manually before moving to another state

asasas
Kilo Contributor

In change request i have following

I have IMPLEMENT UI Button, once it is clicked it will take to Review State

before moving to REVIEW state I need to closed all the task (created manually or from work flow). As you can see that The task is till pending showing above and State has moved to Review.

Please not : I want to make compulsary to user to closed all the task manually, not automatic closed.

Can some help me?

15 REPLIES 15

How Mujtaba?


Chuck Tomasi gave you the code already. But if you want to do in in the UI Action itself then try this



      var parentID = current.sys_id;


      var count = 100;


      var ctask = new GlideAggregate('change_task');


      ctask.addAggregate('COUNT');


      ctask.addQuery('change_request', parentID);


      ctask.addQuery('active', true); // check how many active requests we have


      ctask.query();



      if (ctask.next()) {


                  count = ctask.getAggregate('COUNT');


      }



      // If no active requests were found, then return true (all child tasks are closed)


      if (count == 0) {


                  return true;


      }


addErrorMessage('Please close all open tasks for this change req');


      return false;


Can i put this directly in UI Action script.



It already contain other codes


Yes, put it in the beginning.


11.PNG


This is the scipt screen shot.



Where i can put.



If i am puting in begning it is showing error