Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Reopen Request and Restart Workflow

DChandlerKy
Tera Guru

I know under most circumstances one does not want to reopen a request, but rather open an incident or another request to follow up on the previous.

With that said.... I currently have a catalog item for our Estimators for Voice/Data Services. On occasion, there is a need to go back to a completed estimate, and reopen it in order to change specifications to the request or update quotes from vendors.

There is a business rule that is active called "Request reopened" and it states that if a user changes the state of a request to not be closed, this rule reopens the request.

However, I'm at a loss on where exactly this can be done. I've impersonated a couple ITIL folks and customers with self-service and I'm not able to reopen requests.

My other concern, is how to kick-start the workflow again...

Thoughts?

Thank you!
Diana

4 REPLIES 4

ceulert
Giga Contributor

Hi,

Have you finally find a good solution ?

Regards,


http://wiki.servicenow.com/index.php?title=Condition_Activities#Example_2

That business rule is probably what you are looking for.

HTH,
Subash Biswas


dressman
Kilo Expert

I do this by creating a UI Action on a the catalog task (sc_task) table with condition 'gs.hasRole('itil') && current.state >= 3'
Code as follows:



current.state = "1";
current.work_notes = "Task reopened";
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();
while (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();
while (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();
}



I also allow a user to reopen their own requests but it requires sending a notification every time a request task is closed. It does add some noise but users like the ability it provides. Create an inbound email action for reply


gs.include('validators');

if(current.getTableName() == "sc_task") {
current.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;

if (email.body.assign != undefined)
current.assigned_to = email.body.assign;

if (email.body.priority != undefined && isNumeric(email.body.priority))
current.priority = email.body.priority;

if (email.body.short_description != undefined)
current.short_description = email.body.short_description;

if (email.subject.toLowerCase().indexOf("reopen") >= 0) {
//Reopen the task record
current.state = "1";
current.work_notes = "Task reopened";
}

current.update();

if (email.subject.toLowerCase().indexOf("reopen") >= 0) {
//Reopen the item record & restart the workflow.
var i = new GlideRecord('sc_req_item');
i.addQuery('sys_id', current.request_item);
i.query();
while (i.next()) {
if(i.context != '')
new Workflow().restartWorkflow(i);
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();
while (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();
}
}
}


For the task close notification you can do something like:
If you feel the request is not completed, please click the following link to generate an email to reopen your this task: ${mailto:mailto.unsatisfied.sc_task}. You may also reply to this email with "please reopen" in the subject line. Please provide any additional information within the email that may help us in properly completing the request.

Request Number: ${request_item.request.number}
Request Item Number: ${request_item.number}
Request item Short description: ${request_item.short_description}
Request item Description: ${request_item.description}
Requested for: ${request_item.request.requested_for}

Click here to view task: ${URI_REF}



Number: ${number}
Short Description: ${short_description}
Description: ${description}
State: ${state}
Priority: ${priority}
Opened: ${opened_at}
Due date: ${due_date}

Finally, create an email template 'mailto.unsatisfied.sc_task', with subject 'Re:${number} - please reopen', and message 'Click here to reopen the catalog task' on table sc_task (catalog task). This will setup the reply email if they click on the link.


One gotcha, if you use workflows that create tasks you'll need to create turnstiles in front of the task creation otherwise when you restart your workflow it will just recreate the tasks rather than respecting their current state. So if you had an auto created task and a manually created task and you chose to reopen the request through the manual task then the auto task would be reopened as well and you would have to close both to get the request to close again.