How to reopen the RITM once we set it 'Closed Incomplete' by workflow ? And after that need to create one task on the same RITM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2019 01:35 AM
Hello All,
I just wanted to add the task if the user press one button, which placed at the RITM but when the state of RITM is 'close incomplete' so on that button click, I just want to reopen that RITM so that I can able to add one more task to it..
Thanks,
Ankit.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2019 10:15 AM
I have something similar at the task level that will reopen the task and the RITM. You may be able to adapt the code. However it only reopens the task and the RITM it does not create a new task. This is the code in a UI Action that only displayed when the state is one of the closed states.
current.state = "1";
current.work_notes = "Task reopened";
current.close_notes = "";
current.update();
//Reopen the item record & restart the workflow.
var i = new GlideRecord('sc_req_item');
i.addQuery('sys_id', current.request_item);
i.query();
if (i.next()) {
if(i.context != '')
new Workflow().restartWorkflow(i, true);
i.state = "1";
i.stage = "fulfillment";
i.comments = "Item reopened because task " + current.number + " was reopened.";
i.update();
}
//Reopen the request record
var r = new GlideRecord('sc_request');
r.addQuery('sys_id', current.request_item.request);
r.query();
if (r.next()) {
r.request_state = "in_process";
r.work_notes = "Request reopened because item " + current.request_item.number + " was reopened.";
r.stage = "requested";
r.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-21-2024 10:41 AM
Hello Brian.
How is the behavior of active field of requested item and its request when reopening the sc_task?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-21-2024 03:21 PM
The active flag gets set back to true on the sc_task and the request_item. I have never bothered to check the request and its been a long time since I used this. The BR that interacts between the request item and the request may set the request back to true as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-22-2024 07:25 AM
Thanks! I will dig the rules the instance have and try to combine with your suggestion.