- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2017 08:19 AM
Hi community,
I am trying to close all the change tasks open for any change request that reaches the Review state.
I will not change the workflow to have a script include since I only want for this to happen to certain changes, in this case for the ones I have an Integration with Remedy.
The state in the change workflow is controlled by UI Action, this means that to change the state, it needs to be done manually.
In the case of the integration, we receive a message that automatically change the state to Review. Review is the last state of the workflow.
I have tried to include a BR to have the tasks closed but it seems that it is not working, and I think it should... since I have picked up the code we have on wiki.
BR: onBefore
Table: change_request
var ctask = new GlideRecord('change_task');
ctask.addQuery('change_request', current.sys_id);
ctask.query();
while(ctask.next()){
ctask.state.setValue(3);
ctask.work_notes = "Task automatically closed";
}
current.work_notes = "Tasks automatically closed";
Instead of having the "Closed" state I have "Closed Incomplete".
Any idea of why this is happening?
Thank you in advance!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2017 04:01 AM
I've found a solution for this.
Dumb mistake, it was only missing a ctask.update(); inside the while loop.
All working now
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2017 08:45 AM
I have already check and it is correct, its 3.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2017 02:27 AM
Now I have also to have this in an UI Action and it doesn't work as well.
The task are created in a subflow, is this the problem?
In the UI Action I have
new WorkflowApprovalUtils().cancelAll(current);
new Workflow().restartWorkflow(current);
if (current.number.indexOf("DMN") >= 0){
current.state = 100;
}
else{
current.u_escalated_to_gcab = false;
current.state = -4;
var ctask = new GlideRecord("change_task");
ctask.addQuery("change_request", current.sys_id);
ctask.query();
while(ctask.next()){
ctask.state = 3; //not working
ctask.work_notes = "Test work note"; //not working
}
}
current.update();
Any ideas on this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2017 04:01 AM
I've found a solution for this.
Dumb mistake, it was only missing a ctask.update(); inside the while loop.
All working now