Closing all task manually before moving to another state
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2016 05:07 AM
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?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2016 05:57 AM
Put below code at the start inside function moveToReview().
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 (count != 0) {
addErrorMessage('Please close all open tasks for this change req');
return false;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2016 06:11 AM
I put the above the in script. It is not working
When I am pressing button , It is not taking me anywhere, before it was taking to me other state

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2016 06:15 AM
Can you post a full screen shot of your UI Action including the conditions?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2016 06:18 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2016 06:25 AM
Ok. Here you go.
Step 1: Change Onlick to
chkOpenTasksAndMoveToReview();
Step 2:
Add following function in the script:
function chkOpenTasksAndMoveToReview(){
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 (count != 0) {
addErrorMessage('Please close all open tasks for this change req');
return false;
}
else
{
moveToReview();
}
}