- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2015 04:01 PM
I would like to create an Incident from a UI Action and populate two fields on the incident.
I have this code but it doesn't respond. I have also used the GlideDilogWindow and but I can't seem to pass the values to the Incident form
function redirectToIncident()
{
var uniqueid = current.u_caller_unique_id;
var sysId = current.sys_id;
var url = new GlideURL("incident.do");
url.addParam("sysparm_caller_id", sysId);
url.addParam("sysparm_u_caller_unique_id", uniqueid);
var w = getTopWindow();
w.popupOpenFocus(url.getURL(), '_blank', false, false);
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2015 04:20 PM
There are several ways to do this, what you're doing is a separate popup rather than a redirect. If you want to redirect you can look at the 'Create Problem' UI action for an example in the system. If you want to adjust your code so that you get a popup you could change it to something like this that uses 'sysparm_query' to populate field values as shown here...
Populating Default Values with a URL or Module - ServiceNow Guru
function redirectToIncident(){
//Client-side get record sys_id
var sysID = g_form.getUniqueValue();
//Base URL for creating a new incident record and populating fields via 'sysparm_query' parameter
var url = '/incident.do?sys_id=-1&sysparm_query=';
//Query parameter for populating fields on the incident form. Adjust this as needed.
var urlParams = 'caller_id=' + sysID
//Pop up window
var w = getTopWindow();
w.popupOpenFocus(url + urlParams, '_blank', false, false);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2015 05:32 PM
Hence the other question. What is the field name on the incident you want to populate? What is the field name on the user record that you want to pull over? If you look at the link I sent you it shows how you can just continue to add on to the 'sysparm_query' parameter with whatever field/value pairs you want to populate. If you can tell me that information I can help you get the 'var urlParams' line just right.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2015 05:33 PM
Mark, for the second value can't i just extend the param1
function redirectToIncident()
{
var uniqueid = g_form.getValue(u_caller_unique_id);
var sysId = g_form.getUniqueValue();
var url = "/incident.do?sys_id=-1&sysparm_query=";
var urlParam1 = 'caller_id=' + sysId + '&u_caller_unique_id=' + uniqueid;
var w = getTopWindow();
w.popupOpenFocus(url + urlParam1, '_blank', false, false);
//window.open('incident.do?', '_blank')
// getTopWindow().popupOpenFocus("incident.do?", "_blank", null, null, "");
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2015 05:41 PM
Yes, you can. That's what the article link I sent shows. You've got a couple syntax errors in your script. Copy this exactly and (assuming the field names you've provided are correct) it should work...
function redirectToIncident(){
//Get field values
var sysID = g_form.getUniqueValue();
var uniqueID = g_form.getValue('u_caller_unique_id');
//Construct URL
var url = "/incident.do?sys_id=-1&sysparm_query=";
var urlParam = 'caller_id=' + sysID + '^u_caller_unique_id=' + uniqueID;
//Pop open window
var w = getTopWindow();
w.popupOpenFocus(url + urlParam, '_blank', false, false);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2015 06:59 AM
This worked great with the sysid only.
Now no matter what i do i can't get the screen to pop. I even used the %5E instead of ^ to see if that was the problem.
function redirectToIncident()
{
var uniqueID = g_form.getValue(u_caller_unique_id);
var sysId = g_form.getUniqueValue();
var url = "/incident.do?sys_id=-1&sysparm_query=";
var urlParam = 'caller_id=' + sysId + '^u_caller_unique_id=' + uniqueID;
var w = getTopWindow();
w.popupOpenFocus(url + urlParam, '_blank', false, false);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2015 07:07 AM
Why do you keep re-writing my code? If you pasted it in like I sent to you it would work fine. As it stands, you need quotes around 'u_caller_unique_id' in the first line in your function and I think it will work.