Agent Workspace: How to Pass and Get parameters via URL in Agent Workspace?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-18-2019 02:38 AM
Dear All,
We have an existing setup in ServiceNow to auto populate Requested for & Requested By variables in catalog items when created from an incident.
When Agent click on 'Create Request' in an incident form, we pass the following parameter:
var url = "catalog_home.do?sysparm_view=catalog_default&sysparm_processing_hint=setfield:request.parent=";
url += current.sys_id;
and redirect to above URL.
We have an onload catalog script to get the URL Parameter:
function onLoad() {
var gURL = new GlideURL();
gURL.setFromCurrent();
var value1 = gURL.getParam("sysparm_processing_hint");
var str = value1.replace("setfield:request.parent%3d", "");
var ga1 = new GlideAjax('get_group');
ga1.addParam('sysparm_name', 'Sendincsysid');
ga1.addParam('sysparm_incSysID', str);
ga1.getXML(responseSetVariables);
function responseSetVariables(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer != "" || answer != null) {
var myarray = answer.split(',');
for (var i = 0; i < myarray.length; i++) {
g_form.setValue('requested_by', myarray[0]);
g_form.setValue('u_on_behalf_of', myarray[1]);
}
}
}
}
Same code is not working on Agent Workspace.
We have a new UI Action 'Create Request' on Incident table for agent workspace (Workspace Form Menu is true) available on New York version.
I am unable to pass and get the parameter on script using var gURL = new GlideURL(); system stops script execution. (Also agent workspace URL is embaded and parameter automatically add ASCII code on URL.)
Thanks in advance!
Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-18-2019 02:51 AM
I tied following from ServiceNow guru (https://www.servicenowguru.com/system-ui/glidedialogwindow-advanced-popups-ui-pages/) but compiler stopper executing code after document.URL.parseQuery() line. 😞
function onLoad() {
alert("Running");
var myparm = getParmVal('sysparm_parent_sys_id');
alert("myparm>" + myparm);
function getParmVal(name) {
alert("Inside function");
var url = document.URL.parseQuery();
alert("after url");
if (url[name]) {
return decodeURI(url[name]);
} else {
return;
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-18-2019 02:51 AM
did you try to set the isolate script field as false ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-18-2019 03:14 AM
I tried by marking 'Isolate Script' to true but again stopped executing.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-18-2019 03:17 AM
if you want to execute the client side code on work space then you have to write the script in "Workspace Client Script".
refer the doc link for further details.