Get parameters from the URL in the Service Catalog record producer

wilson18
Kilo Contributor

Hello everybody. This is my first post here so apologies if I am doing anything stupid.

So, I am trying to create a service catalog record producer to take some inputs from the user (obviously) but I also need to get a parameter from the URL. I have been trying (unsuccessfully) to do this in the 'What it will contain' script section.

All the links I have found suggest this: Parse URL Parameters in a Client Script - ServiceNow Guru

When doing this however, the logs say about document not been defined in javascript. Is there any other way of getting a specific param from the URL?

The error message is here:

org.mozilla.javascript.EcmaError: "document" is not defined.

Caused by error in Record Producer: 'Add dish to Order' at line 11

8: }

9:

10: function getParmVal(name){

==> 11: var url = document.URL.parseQuery();

12: if(url[name]){

13: return decodeURI(url[name]);

14: }

Thanks for any help, it would be very much appreciated.

5 REPLIES 5

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Chris,



You may find below blog helpful.


3 Ways to Populate Values in ServiceNow via the URL


Chuck Tomasi
Tera Patron

Hi Chris,



I've been seeing this pop up in more and more client scripts. Haven't tried it in a catalog client script, but it's worth a try.



var gURL = new GlideURL();
gURL.setFromCurrent();
var user = gURL.getParam("sysparm_user");


(don't ask why this HTML editor decided a table was the right thing for a straight text copy/paste)


Doing this got me the error Glide URL is not allowed in scoped applications



after working on this for many hours, I decided to take another approach and I managed to get the information via another method which is probably more secure then taking the data from the url.



Thanks for your help though - I will come back to this (when I dont have a deadline for a couple of hours!) and play around with this!


Thanks Chris. Care to share what your solution was?