Restrict change closure if there are open tasks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2017 06:08 PM
Hi,
I have coded as per below in an before update BR.
var task=new GlideRecord('Change_Task');
task.addJoinQuery('change', current.number,'change_task.number');
task.query();
while (task.hasnext())
{
if (task.state != 'Closed Complete')
gs.addErrorMessage('Ticket cannot be moved to Closed');
}
But it is not working. Can you help here?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2017 03:48 AM
Hi ramkrish,
If I have answered your question, would you mind marking my Answer as Correct and close the thread? So that it can be tracked later by others in need.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2017 10:01 PM
Hi ramkrish ,
May I know the status of this thread? Please mark my Answer Correct, if you already got the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2017 01:18 AM
Hi,
On Close UI action you can do this check, this works in our instance.
function moveToClosed(){
var ch_id = g_form.getUniqueValue();
//alert(ch_id);
var task_stat;
var diff;
//check for change tasks. They need to be closed before a change is closed
var ch_task = new GlideRecord('change_task');
ch_task.addQuery('change_request',ch_id);
ch_task.query();
while(ch_task.next())
{
task_stat = ch_task.state;
if(task_stat != '3')
{
alert('Please close the change tasks - '+ch_task.number +' before the change request is closed.');
diff='1';
}
}
if(diff != '1')
{
g_form.setMandatory('close_code',true);
g_form.setMandatory('close_notes',true);
var ga = new GlideAjax("ChangeRequestStateHandlerAjax");
ga.addParam("sysparm_name", "getStateValue");
ga.addParam("sysparm_state_name", "closed");
ga.getXMLAnswer(function(stateValue) {
g_form.setValue("state", stateValue);
gsftSubmit(null, g_form.getFormElement(), "state_model_move_to_closed");
});
}
}
if (typeof window == 'undefined')
{
//updateinc();
setRedirect();
}
function setRedirect() {
current.update();
action.setRedirectURL(current);
}
Thanks,
VInitha.K
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2017 03:25 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2017 03:29 AM