- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2019 08:52 AM
Hi,
I don't want to move change state to review until all Ctask are closed which were opened on Implementation. Currently it allow to use Review UI action and Ctasks get closed incomplete. I want to abort the change movement until the chnage tasks are closed and pop up an alert if review Action pressed without closing the ctasks.
Thanks and Regards,
Jitendra singh
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2019 11:00 AM
The review ui action in our change request has the following conditions set along with the script below. This stops the move to review state until the tasks are closed.
function moveToReview(){
//Check for remaining tasks before moving to Review
g_form.clearMessages();
//Type appropriate comment here, and begin script below
var gr = new GlideRecord("change_task");
gr.addQuery("change_request","=",g_form.getUniqueValue());
gr.addQuery("state","<","3"); //anything less than 3 is not closed
gr.setLimit(1);
gr.query(); //purposefully not async
if(gr.next()) {
g_form.addErrorMessage("Cannot move to Review state while Change Tasks are open");
return false;
}
else {
//no remaining tasks, move to Review
var ga = new GlideAjax("ChangeRequestStateHandlerAjax");
ga.addParam("sysparm_name", "getStateValue");
ga.addParam("sysparm_state_name", "review");
ga.getXMLAnswer(function(stateValue) {
g_form.setValue("state", stateValue);
gsftSubmit(null, g_form.getFormElement(), "state_model_move_to_review_new");
});
}
}
if (typeof window == 'undefined')
setRedirect();
function setRedirect() {
current.update();
action.setRedirectURL(current);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2020 10:10 AM
Hi Bridget,
your suggestion helped me last time. Now I want that even if a manual change task is added this functionality work same way with manual change task also. Can you suggest a solution for this also.
Regards,
Jitendra Singh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2020 11:00 AM
Hi - this may be what you're looking for.
We have a before update business rule set as follows with the script below on the Advanced tab
Advanced tab
Condition: new ChangeRequest(current).changesToClosed()
Script:
(function executeRule(current, previous /*null when async*/) {
if (hasOpenTasks(current.sys_id)) {
gs.addErrorMessage(gs.getMessage('Unable to close the Change request as there are open Change tasks'));
current.setAbortAction(true);
//action.setRedirectURL(current);
}
function hasOpenTasks(sys_id)
{
var cTaskAgg = new GlideAggregate('change_task');
cTaskAgg.addQuery('change_request', sys_id);
cTaskAgg.addQuery('u_bypass_close_check','=','false');
cTaskAgg.addActiveQuery();
cTaskAgg.addAggregate("COUNT");
cTaskAgg.query();
if (cTaskAgg.next())
return (cTaskAgg.getAggregate("COUNT") > 0);
return false;
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-14-2024 03:57 AM
Hi Bridget,
I tried your solution (actually both of them) but they dont work for me and I dont know why...I am still able to move to review phase, but I am not able to move to close/cancel state till the tasks are closed or cancelled, could you help me? Could be problem with this because of new releases of SMnow?