- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2017 11:48 AM
Hi,
This is the requirement.
1. Create a Request ticket from an Incident. When 'Create Request' is clicked, it should trigger the current Incident to canceled state and create a request ticket with the details provided in the Incident form.
2. Also, vice versa. Create a Incident ticket from Request. When 'Create Incident' is clicked on the Request form, it should trigger the current request to canceled state and create an Incident ticket with the details provided in the request form. Has anyone does this?
Can anyone put me in the right direction and tell how to do this?
Thanks,
Rajini
Solved! Go to Solution.
- Labels:
-
Best Practices
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2018 05:37 AM
Well this is what we use:
UI Action
//Client-side 'onclick' function
function ReqWarning() {
var answer = confirm("Please confirm Request to Incident Action.");
if (answer == false) {
return false;
}
gsftSubmit(null,g_form.getFormElement(),'cancel_req_create_inc');
}
//Code that runs without 'onclick'
//Ensure call to server-side function with no browser errors
if (typeof window == 'undefined')
//serverCancelPrj();
createIncident();
function createIncident() {
var inc = new GlideRecord("incident");
inc.short_description = current.short_description;
inc.description ="" + "Converted to Incident from: " + sc_req_item.request.number + "\n" + "\n\n" + "Description: " + current.description + '\n\n' + current.comments.getJournalEntry(3) + '\n\n' + current.work_notes.getJournalEntry(3);
//inc.priority = current.priority;
//inc.u_current_phone__ = current.u_current_phone;
//inc.location = current.location;
//inc.assignment_group = "f2a518706f7d91005ce5d2054b3ee4ca"; //Help Desk - to make sure INC has an group, then HD can re-assign
//inc.u_room = current.u_room;
//inc.u_affected_workstation.ip_address = current.u_ip;
inc.caller_id = current.request.requested_for;
inc.location = current.location;
inc.u_current_phone = current.u_phone;
inc.u_region = current.location.u_region;
inc.parent = current.request;
inc.cmdb_ci = current.cmdb_ci;
inc.impact = 3;
inc.urgency = 3;
current.parent = inc.insert();
current.comments = "" + "Converted Request to Incident: " + inc.number;
current.close_notes = "Converted Request to Incident: " + inc.number;
abortKids();
current.state = 4;
GlideSysAttachment.copy('sc_req_item', current.sys_id, 'incident', inc.sys_id);
current.update();
gs.addInfoMessage("Remember to set Assignment Group");
gs.addInfoMessage("Incident " + inc.number + " created");
action.setRedirectURL(inc);
action.setReturnURL(current);
}
function abortKids() {
if (current.sys_id == '')
return;
var kids = new GlideRecord('sc_task');
kids.addQuery('parent', current.sys_id);
kids.query();
while (kids.next()) {
kids.state = 4;
kids.close_notes = "Task closed - Request Converted to Incident";
kids.update();
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2017 11:57 AM
Out of the box in Helsinki, there is a UI Action on Incident table named Create Request.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2017 01:17 AM
This was exactly what I needed, thank you Sir!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2017 01:22 PM
Michael,
I too saw that, but it is taking me to the catalog landing page.
I want that UI Action to create the Request ticket.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2017 11:13 AM
Here is the UI Action we currently have, you'll need to modify the script to your 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 Misc 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);
}