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

Community Alums
Not applicable

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.

6 REPLIES 6

Brian Lancaster
Tera Sage

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();
}

Hello Brian.

How is the behavior of active field of requested item and its request when reopening the sc_task?

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.

Thanks! I will dig the rules the instance have and try to combine with your suggestion.