Reopen a closed RITM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2018 01:08 AM
Hi All
RITM has been marked as closed complete and workflow is ended. Now I want to create an UI Action to "Reopen RITM".
Once I click on that button , it should create new tasks and RITM state should change to open and tasks should work according to RITM workflow.
Please assist on this issue.
Thank you

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2018 01:16 AM
I've been asked to work on something like this before but I really wouldn't recommend it. RITMs are intended to have a very linear request-approve-fulfil workflow and don't lend themselves very well to being re-opened and re-worked. For one thing, you'd lose your audit information regarding the previous submission, and if your workflow has multiple tasks, how would you know which to re-open?
What I have done previously is send an email to the requestor should an RITM be closed incomplete, for instance if the approval is rejected. The email would contain a link which the user could click to go back to the catalog item for them to re-submit. The subtle difference is that the link contains the rejected RITM number as a parameter, which means that the old values from the request are copied into the new item form, and therefore the user doesn't have to re-key. I don't have the code to hand, but let me know if this is of interest and I can dig it out.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2018 02:02 AM
Thanks for the information. I think email to re-submit a request is a good idea. Could you please provide more information on this?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2018 02:08 AM
Hi, I need some time to dig this out so let me get back to you later today on this...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2018 05:30 AM
So, you'll need to add a link to your catalog item that the user can click on that will take them to the Catalog Item. You can include this link in the approval rejected notification which the user will receive when that RITM is rejected:
../com.glideapp.servicecatalog_cat_item_view.do?v=1&sysparm_id=***CAT ITEM SYS_ID ***&rejected_ritm=*** SYS_ID OF REJECTED RITM***
Here's an example of a notification script that can be used to generate this link. This script will work for emails generated on the sysapproval_approver table, but can be easily adapted to work elsewhere:
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var gr = new GlideRecord("sc_req_item");
gr.get(current.document_id);
template.print("<a href='../com.glideapp.servicecatalog_cat_item_view.do?v=1&sysparm_id=" + gr.cat_item +
"&sysparm_link_parent=" + gr.cat_item.category + "&sysparm_catalog=" + gr.cat_item.category.sc_catalog +
"&sysparm_catalog_view=catalog_default&rejected_ritm="+ gr.sys_id + "' target='_blank'>" +
gs.getMessage("Click here to re-submit your catalog item.") + "</a>");
})(current, template, email, email_action, event);
Here's a client script that you can add to your Catalog Item that will populate the variables:
function onLoad() {
var url = document.URL.parseQuery();
if(url["rejected_ritm"]){
var rejectedRITM = decodeURI(url["rejected_ritm"]);
var ga = new GlideAjax("DmnsCatalogItemUtils");
ga.addParam("sysparm_name", "getRitmVars");
ga.addParam("sysparm_ritm", rejectedRITM);
ga.getXMLAnswer(setVars);
}
function setVars(answer) {
var fieldArray = JSON.parse(answer);
for(var key in fieldArray) {
g_form.setValue(key, fieldArray[key]);
}
}
}
This script include will require the following Script Include to return the old RITM variables from the server. Ensure to check 'client callable' on this script as otherwise it won't work:
var DmnsCatalogItemUtils = Class.create();
DmnsCatalogItemUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getRitmVars: function() {
var ritmID = this.getParameter("sysparm_ritm");
var ritm = new GlideRecord("sc_req_item");
ritm.get(ritmID);
var oVariables = {};
for(var key in ritm.variables)
oVariables[key] = ritm.variables[key] + '';
return JSON.stringify(oVariables);
},
type: 'DmnsCatalogItemUtils'
});
Please let me know how you get on with this, cheers.