Is access to window.location in client script restricted?

Ravish Shetty
Tera Guru

hi all,

is the access to 'window.location' restricted in client scripts? my use use is to get the paramters from the URL and then process the information. I get below error when i try to use the 'window.location' object in the code. what is the workaround?

find_real_file.png

Ravish

1 ACCEPTED SOLUTION

Prateek kumar
Mega Sage

Check this out:

https://community.servicenow.com/community?id=community_question&sys_id=b153909ddb7f23c0e0e80b55ca96...


Please mark my response as correct and helpful if it helped solved your question.
-Thanks

View solution in original post

4 REPLIES 4

Prateek kumar
Mega Sage

Check this out:

https://community.servicenow.com/community?id=community_question&sys_id=b153909ddb7f23c0e0e80b55ca96...


Please mark my response as correct and helpful if it helped solved your question.
-Thanks

Thanks Prateek.

Anurag Tripathi
Mega Patron
Mega Patron

Hi Ravish,

I use this to read url parameters

 

var id = getParmVal('<parameter name>');  //place this in the main function in client script

 

 

//place this function in the same script, out of the main function
function getParmVal(name){
var url = document.URL.parseQuery();
if(url[name]){
return decodeURI(url[name]);
}
else{
return;
}

-Anurag

Hi Anurag, Its now working. per this post, seems like document and window object are no longer supported in regular or service portal view.