Get parameters from the URL in the Service Catalog record producer
This content was last updated in 2016. It may still be useful, but could contain outdated information. Please confirm its accuracy before relying on it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2016 04:06 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2016 04:27 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2016 04:31 PM
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)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2016 04:48 PM
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2016 04:53 PM
Thanks Chris. Care to share what your solution was?