- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2019 12:06 PM
"Create Request" button on Incident table redirects to Service Catalog home page. We would like to configure this to trigger the current incident to canceled state and create a request ticket with details provided in the Incident form. Would also like same behavior when using "Create incident" from Request. Will appreciate any assistance you are able to provide to set this up.
I read a few post on community about this but none of them are clear to me. I also know this will require scripting which I am not very good at so I am hoping for a very simplified solution if possible. Thanks you.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2019 10:35 AM
You can use current to set your field values before the current.update(); line
so current.incident_state =. x;
current.close_code = x;
current.close_notes = x;
then current.update(); <- this line saves the current record before showing the catalog.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2019 12:19 PM
Please check below thread for solution to your both requirements.
https://community.servicenow.com/community?id=community_question&sys_id=54f4872ddbd8dbc01dcaf3231f9619ce
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2019 12:27 PM
Why exactly is this script supposed to be configured? On the UI Action script area? Is there an OOTB script that works? The script on the link is heavily customized and will take some scripting expertise to tailor it for my needs.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2019 12:30 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2019 12:34 PM
The form linked by Sachin was helpful for Create Request from Incident. But I am struggling a little with Creating Incident from Request. The workflow does not progress. It is using the default Service Catalog Request workflow. I like to change that to a custom workflow. How do I proceed. Also the email sent when the RITM is submitted contains variables that I have no idea where they are pulled from. Those variables are not defined on the script I am using. I am modifying the script below for my needs;
//Client-side 'onclick' function
function IncWarning() {
var answer = confirm("Please confirm Incident to Request Action.");
if (answer == false) {
return false;
}
gsftSubmit(null,g_form.getFormElement(),'cancel_inc_create_req');
}
//Code that runs without 'onclick'
//Ensure call to server-side function with no browser errors
//if (typeof window == 'undefined') //serverCancelPrj();
createCart();
function createCart() {
var cart = new Cart();
var item = cart.addItem('ea8f4a5e4fdab680e52350ee0310c7e4');
cart.setVariable(item, 'requested_for', current.caller_id.sys_id.toString());
cart.setVariable(item, 'requested_by', current.caller_id.sys_id.toString());
cart.setVariable(item, 'short_description', current.short_description);
cart.setVariable(item, 'phone', current.u_current_phone);
cart.setVariable(item, 'location', current.location);
cart.setVariable(item, 'description', 'Converted to Request from: ' + current.number + '\n\n' + "Incident Description: " + current.description + '\n\n' + current.comments.getJournalEntry(3) + '\n\n' + current.work_notes.getJournalEntry(3));
// cart.setVariable(item, 'assignment_group', current.assignment_group);
// cart.setVariable(item, 'assigned_to', current.assigned_to);
var rc = cart.placeOrder();
current.close_code = 'Not Solved (is a Request)';
current.close_notes = 'Opened in Error, converting to Request';
current.comments = 'Converted Incident to Request: ' + rc.number;
//sets the REQ on the parent INC
current.u_request = rc.sys_id.toString();
current.reassignment_count = 1;
current.state = 6;
GlideSysAttachment.copy('incident', current.sys_id, 'sc_request', rc.sys_id);
//Update saves incidents before going to the catalog homepage
current.update();
var fp = new GlideRecord('sc_request');
fp.addQuery('sys_id', '=', rc.sys_id);
fp.query();
while (fp.next()){
fp.parent = current.sys_id;
fp.watch_list = current.watch_list.getDisplayValue().toString();
fp.cmdb_ci = current.u_application;
fp.update();
}
action.setRedirectURL(rc);
}