I've had this question come up over and over again in my career:
How do we populate variables on a catalog item or record producer, from the URL?
There are a number of reasons why you might want to do this - for example, imagine you have a generic access request catalog item that lets you choose a group, enter the business justification, and request access to that group.
If you then have a knowledge article about “how to get access to [some system]” that involves filling out that access request form, and requesting to be added to a specific group, you might want to include a link that takes you directly to that catalog item, and pre-populates the relevant variable for you!
There are a couple of ways to do this, but I’ve always only found one-off solutions that require custom code for each and every catalog item, which also means that you have to know in advance, when designing the catalog item, what variables might be specified by URL, their data types, etc.
I got tired of re-engineering the same basic solution over and over again, so I built a generalized tool that should handle all of these potential scenarios. This tool adds to your system, a Variable Set. This variable set contains a catalog client script, but no actual variables (this is expected). The variable set is called “Parse sysparm_variables URI param”.
Once you’ve added the variable set to a given catalog item, you can populate any one or more variables in that catalog item, simply by manipulating the URL.
Simply add a single URI parameter (sysparm_variables) to the URL for any catalog item, and set its value to a JSON-encoded string, with each variable you'd like to populate, and its value.
You can specify any number of variables and values in this JSON object, as long as you encode any illegal characters (which most browsers will do for you automatically).
Once you've added the "variable set" containing the necessary script to a catalog item, the exact same sysparm_variables URI parameter, will work for URLs pointing to both the portal, and the classic UI:
Additional detailed documentation, and the download link for this free tool is available at the link below, or you can find it by going to Tools > Set Catalog Item Variables from URL in the navigation bar at the top of this site.
- Apr 21, 2019 Understanding Attachments in ServiceNow
- Apr 10, 2019 Using Custom Search Engines in Chrome to Quickly Navigate ServiceNow
- Apr 4, 2019 Set Catalog Variables from URL Params (Free tool)
- Apr 1, 2019 Outlook for Android Breaks Email Approvals (+Solution)
- March 2019
- Feb 27, 2019 Making Update Sets Smarter - Free Tool
- November 2018
- October 2018
- September 2018
- Jul 23, 2018 Admin Duty Separation with a Single Account
- Jun 19, 2018 Improving Performance on Older Instances with Table Rotation
- Jun 4, 2018 New Free Tool: Login Link Generator
- May 29, 2018 Learning ServiceNow: Second Edition!
- April 2018
- March 2018
- Feb 11, 2018 We have a new book!
- November 2017
- Sep 12, 2017 Handling TimeZones in ServiceNow (TimeZoneUtil)
- July 2017
- June 2017
- May 2017
- April 2017
- Mar 12, 2017 reCAPTCHA in ServiceNow CMS/Service Portal
- Dec 20, 2016 Pro Tip: Use updateMultiple() for Maximum Efficiency!
- Dec 2, 2016 We're Writing a Book!
- Nov 10, 2016 Chrome Extension: Load in ServiceNow Frame
- September 2016
- Jul 17, 2016 Granting Temporary Roles/Groups in ServiceNow
- Jul 15, 2016 Scripted REST APIs & Retrieving RITM Variables via SRAPI
- May 17, 2016 What's New in Helsinki?
- Apr 27, 2016 Customizing UI16 Through CSS and System Properties
- Apr 5, 2016 ServiceNow Versions: Express Vs. Enterprise
- March 2016
- Feb 22, 2016 Reference Field Auto-Complete Attributes
- Feb 6, 2016 GlideRecord & GlideAjax: Client-Side Vs. Server-Side
- Feb 1, 2016 Make Your Log Entries Easier to Find
- Jan 29, 2016 A Better, One-Click Approval
- Jan 25, 2016 Quickly Move Changes Between Update Sets
- Jan 20, 2016 Customize the Reference Icon Pop-up
- Jan 7, 2016 ServiceNow: Geneva & UI16 - What's new
- Jan 4, 2016 Detect/Prevent Update Set Conflicts Before They Happen
- Dec 28, 2015 SN101: Boolean logic and ServiceNow's Condition Builder
- Dec 17, 2015 Locate any record in any table, by sys_id in ServiceNow
- Dec 16, 2015 Detecting Duplicate Records with GlideAggregate
- Dec 11, 2015 Array.indexOf() not working in ServiceNow - Solution!
- Dec 2, 2015 Understanding Dynamic Filters & Checking a Record Against a Filter Using GlideFilter
- October 2015
- Aug 27, 2015 Easily Clone One User's Access to Another User