Passing Parameters through the URL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2014 11:14 AM
I have successfully been able to create a UI Action that creates a URL with specific parameters that I pass to a catalog item and then will be rerouted to the item. The catalog item opens with no issues and is then populated with the specific parameters. I am using a catalog client script — onLoad in order to read and parse the URL and to set fields in the form.
My issue. This only works in the backend of the system. The front end, where a user would be redirected, does not populate the form. Any clues as to why.
- Labels:
-
Service Mapping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2014 06:35 AM
Interesting! I got it to work. When I swap the order of setvalue and setreadonly It works fine in the backend and the Front end.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2014 01:39 PM
I know that mandatory fields cannot be made read-only or hidden. Maybe there is a similar constraint for changing the value of read-only fields... However, I could not reproduce it in Dublin or Eureka. What version of ServiceNow are you using?
Blog: https://sys.properties | Telegram: https://t.me/sys_properties | LinkedIn: https://www.linkedin.com/in/slava-savitsky/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2014 06:36 AM
Have you tried setting the values of the g_form fields before making them readonly?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2014 07:58 AM
Hi Timothy,
Can you check this link probably you will get solution.
CMS pass catalog variables via custom URL
Regards,
Harish.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2016 03:08 PM
Hi Timothy -
I was able to do something similar.
When users are in a printer record, I wanted the system to update the record, redirect them to request queues to be setup for the printer which is a Catalog Item and pass in the printer's sys id into the catalog item automatically.
This is what I did to accomplish that.
1). I created a UI Action (here is the code for the UI Action):
//Update current printer record
current.update();
// Pass the Sys id of the current Printer Record to the OnLoad Client Script "Enter Printer" and enter in the Printer Queue Request when redirected
var thisHost = "./com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=[enter the sys id]&sysparm_catalog_view=catalog_default" + "&sysparm_pID=" + current.sys_id;
action.setRedirectURL(thisHost);
2). I also created a OnLoad Client Script (here is the code for the Client Script):
function onLoad() {
function getParmVal(name){
var url = document.URL.parseQuery();
if(url[name]){
return decodeURI(url[name]);
}
return;
}
// Finding if open by url or empty
var myparm = getParmVal('sysparm_pID') || 'N/A';
if (myparm == 'N/A') {
return;
}
// value returned is the sysid, and field name
myparm = myparm.split(',')[0];
g_form.setValue('variables.variable name',myparm);
// Reference the Printer record selected and set the values
var printer_sn = g_form.getReference('variable name').serial_number;
var printer_dep = g_form.getReference('variable name').department;
var printer_dup = g_form.getReference('variable name').u_duplex;
g_form.setValue('variable name',printer_sn);
g_form.setValue('variable name',printer_dep);
g_form.setValue('variable name',printer_dup);
}
I hope this helps.