- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2022 03:13 PM
I have a generic Get Help request item (none IT).
There are times I need to convert this to an INC because user submitted wrong form. I found a system UI Action "Create Incident" but it only copies the requestor name. How can I get the variable values from the RITM and pass those to the new INC being created. Only need a couple of variables passed from requested item to inc and the watchlist.
UI Action Script
var url = new GlideURL("incident.do");
url.set("sys_id" , "-1");
if(current.requested_for) {
url.set("sysparm_query" , "caller_id=" + current.requested_for + "^parent=" + current.sys_id);
}
else {
url.set("sysparm_query" , "caller_id=" + current.request.requested_for + "^parent=" + current.sys_id);
}
action.setRedirectURL(url.toString()+"");
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2022 09:08 AM
Here is the code that I finalized that did work. I added a lengthy query with the additional variables to be copied into the new INC form.
var url = new GlideURL("incident.do");
url.set("sys_id", "-1");
if (current.requested_for) {
url.set("sysparm_query", "caller_id=" + current.requested_for + "^parent=" + current.sys_id);
} else
url.set("sysparm_query", "caller_id=" + current.request.requested_for + "^parent=" + current.sys_id);
url.set("sysparm_query", "short_description=" + current.variables.request_title + "^watch_list=" + current.watch_list + "^description=" + current.variables.details + "^contact_type= Tech");
//gs.log("CREATEINC: variables.request_title="+current.variables.request_title);
action.setRedirectURL(url.toString() + "");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2022 09:08 AM
Here is the code that I finalized that did work. I added a lengthy query with the additional variables to be copied into the new INC form.
var url = new GlideURL("incident.do");
url.set("sys_id", "-1");
if (current.requested_for) {
url.set("sysparm_query", "caller_id=" + current.requested_for + "^parent=" + current.sys_id);
} else
url.set("sysparm_query", "caller_id=" + current.request.requested_for + "^parent=" + current.sys_id);
url.set("sysparm_query", "short_description=" + current.variables.request_title + "^watch_list=" + current.watch_list + "^description=" + current.variables.details + "^contact_type= Tech");
//gs.log("CREATEINC: variables.request_title="+current.variables.request_title);
action.setRedirectURL(url.toString() + "");

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2022 07:13 PM
I'm glad you got your solution working!
For reference, you've opted to leverage ServiceNow's capability to apply field values to a record form via URL parameters. In my experience, this works for simple field values (reference fields/sys_id's, choice fields, true/false fields etc.), but you may find it doesn't work when you're putting large bodies of text into those fields via URL parameters.
I noticed you're mapping "current.variables.details" into the Incident Description field. If the source variable type is multi-line text, it has the potential to contain a large amount of text, and that text may include special characters that would otherwise need escaping. I recommend testing your solution for such inputs to confirm it still works as expected.