No history yet

Advanced Variable Management

Beyond Simple Forms

You've mastered the basics: single-line text fields, select boxes, and simple reference fields. But real-world service requests are rarely that simple. Users need to request software for multiple new hires, specify server configurations with interdependent parts, or navigate complex onboarding processes. This is where advanced variable management comes in.

To build powerful, user-friendly forms in ServiceNow, you need tools that can handle dynamic, repetitive, and conditional data. Let's move beyond the simple variables and explore the structures that support enterprise-scale service catalogs.

Capturing Data in Rows

Imagine a user needs to request five different software licenses for a new team. A standard form would be a mess of duplicated fields: "Software 1," "User 1," "Software 2," "User 2," and so on. It's clunky for the user and a nightmare to process on the backend.

The solution is a (MRVS). Think of an MRVS as a mini-spreadsheet embedded directly within your catalog item form. It allows users to add as many rows of information as they need, with each row containing a consistent set of variables. This is perfect for ordering multiple pieces of hardware, requesting access for a list of users, or detailing firewall rule changes.

Lesson image

To configure an MRVS, you create the variable set and then add other variables inside it, just as you would for a standard catalog item. These become the columns of your table. You can then add this MRVS to any catalog item.

Dynamic and Contextual Filtering

A List Collector variable lets users select multiple records from a table. But what if you only want to show them a subset of those records? For example, when a user selects a department, you might want the 'User' list collector to only show employees from that department.

This is achieved with advanced and dynamic filtering. A reference qualifier is essentially a filter applied to a reference field or list collector, restricting the choices available. While simple qualifiers are static (e.g., active=true), advanced qualifiers can be dynamic by calling a Script Include.

javascript:
// Example for a list collector variable pointing to the User [sys_user] table.
// This qualifier calls a Script Include named 'UserUtils' and a function 'getUsersFromDepartment'.
// It passes the value from another variable on the form, 'department_field'.

javascript:'sys_department=' + current.variables.department_field

For even more complex, client-side interactions where the filter depends on multiple fields or requires logic that can't be expressed in a simple query, you can use GlideAjax in a client script. The script would watch for changes on the form, call a Script Include to get the right query, and then apply it to the list collector dynamically. This approach offers maximum flexibility but adds complexity.

Guiding the User's Request

An Order Guide is used for complex requests that bundle multiple catalog items, like onboarding a new employee. The user fills out one initial form with details like the employee's name, role, and location. Based on these answers, the Order Guide presents a set of relevant catalog items—a laptop, software access, a phone, etc.

To avoid forcing the user to re-enter the same information on each item, we use cascading variables. If a variable on the initial Order Guide form has the exact same name as a variable on one of the included catalog items, its value will be automatically passed down, or "cascaded."

Best practice: Use Variable Sets to ensure your cascaded variables are consistent. If the 'New Hire Details' variables are in a set, you can add that same set to the Order Guide and all relevant catalog items to guarantee the names match perfectly.

Sometimes, you need to show or hide entire sections of a form at once. Instead of writing a complex UI Policy for every single variable in a section, you can group them into Containers. A container is a special type of variable that acts as a visual wrapper for other variables.

You can then write a single UI Policy or client script that toggles the visibility of the container itself. This makes your logic much cleaner and easier to maintain. You can even create nested layouts with containers that split the form into multiple columns, improving the visual organization of complex requests.

Quiz Questions 1/5

A manager needs to request 10 different software licenses for a new team of developers. Which ServiceNow variable type is best suited for creating a clean, user-friendly form that allows them to add each license request as a separate line item?

Quiz Questions 2/5

When building an Order Guide for new employee onboarding, how can you ensure the 'New Employee Name' entered on the initial form is automatically populated into the 'Requested For' field on the included catalog items?

By mastering these advanced variable types and organizational strategies, you can transform your Service Catalog from a simple list of items into a powerful, intuitive platform for managing complex enterprise requests.