issue with glideURL in service portal

swati38
Tera Expert

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,

Swatifind_real_file.png

9 REPLIES 9

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Swati,



Can you share the script here?



Regards


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

sndangibbard
Mega Guru

GlideURL is not supported in Service Portal, you should use the $location AngularJS Service. Example:



function($location){


var queryStringParams=$location.search()


}



more documentation here:


AngularJS


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);


}


}


}


}


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


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader