issue with glideURL in service portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2017 03:32 AM
Hi,
I have an issue with the on load client script that uses GlideURL. On load of the form, we face an issue at the browser.
Kindly refer to the screenshot.
Thanks,
Swati
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2017 03:49 AM
Hi Swati,
Can you share the script here?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2017 04:13 AM
GlideURL is not supported in Service Portal, you should use the $location AngularJS Service. Example:
function($location){
var queryStringParams=$location.search()
}
more documentation here:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2017 09:11 PM
Hi Dan and Ankur,
I have used catalog client script.
And Dan as you have mentioned those methods are supported in the client scripts for Widgets.
I am implemeting this in the catalog.
Below is the code for the catalog client script:
function onLoad() {
console.log("inside Onload");
var group='';
var splitVal='';
var variable='';
var optLabel='';
var optVal='';
var res=[];
var order='';
var answergrp='';
var ansgrp='';
var order1='';
var userID= g_user.userID;
var url= new GlideURL();
url.setFromCurrent();
var sysid=url.getParam('sysparm_id');
var requested= url.getParam('sysparm_record_target');
if(requested=='sc_req_item'){
sysid=url.getParam('sys_id');
}
var ga= new GlideAjax('cloud_options_util');
ga.addParam('sysparm_name','optionCheck');
ga.addParam('sysparm_sysid',sysid);
ga.addParam('sysparm_sysuid',userID);
ga.addParam('sysparm_requested',requested);
ga.getXML(ans);
function ans(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
var jsans= JSON.parse(answer);
for(var i=0;i<jsans.length;i++)
{
variable=jsans[i].variable;
group=jsans[i].mem;
optLabel=jsans[i].label;
optVal=jsans[i].value;
order1= jsans[i].order;
if(group=='true'){
if (typeof g_sc_form != "undefined")
g_sc_form.addOption(variable,optVal,optLabel,order1);
else
g_form.addOption(variable,optVal,optLabel,order1);
}
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2017 09:34 PM
Hi Swati Priya,
Did you check you are able to get the URL by adding console statement.
var url= new GlideURL();
url.setFromCurrent();
console.log(url);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader