OBLYTECH Logo
OBLYTECH Logo

ServiceNow URL Parameters: Open Forms, Lists and Records

ServiceNow URL parameters are text added to the end of an instance address. They tell the platform which form, list or record to open and what to show: a filter, a sort order, a row limit, a view, or field values for a new record. The core parameters are sysparm_query, sysparm_view, sysparm_order and sysparm_force_row_count.

How the address of a ServiceNow page is built

Each instance has its own secure address in the form of the instance name followed by the service-now domain. The page path comes after it. A table name followed by _list opens that table as a list, so the incident table opens with the list suffix. Any other page is reached by its page name followed by .do. A record opens in form view when its sys_id is supplied. Setting the sys_id to -1 opens a blank form for a new record instead.

If you want the standard interface, with the banner frame and the application navigator on screen, the address uses the navigation wrapper nav_to.do with a uri parameter that holds the page path.

Parameters are separated from the path and from each other by an ampersand. Inside a parameter value, a caret joins several conditions together, so two conditions in one query are written with a caret between them.

Filtering a list with sysparm_query

On a list, sysparm_query returns the records that match its conditions. A single condition looks like number=INC00040, which returns the one incident with that number. Two conditions are joined with a caret, so priority=2^active=true returns active records at priority 2.

The query language also supports grouping. A clause such as ^EQ^GROUPBYcategory at the end of a query groups the results by the category field. Grouping is a query-level instruction, so it sits inside the same parameter as the filter conditions.

Opening a new form with preset field values

The same parameter behaves differently on a form. When the sys_id is -1, sysparm_query applies its values to the new record instead of filtering anything. This is the simplest way to start a form with fields already filled. The field names and values are written as field=value pairs, joined by carets, exactly as in a list query.

A typical use is a link placed in an email, a knowledge article or an intranet page that opens a request form with the category and priority already set, so the person has just to describe the problem.

Sorting, limiting and choosing a view

Four parameters control how results appear on a list:

Parameter What it does Example value
sysparm_order Sets the field used to sort number
sysparm_order_direction Sets the sort direction desc
sysparm_force_row_count Caps the number of rows returned 5
sysparm_view Chooses a view, which decides which fields show on a form or list ess

The view parameter matters when more than one layout exists for the same table. A view defines the elements that appear when someone opens a form or a list, so the same record can show a shorter set of fields for one audience and a fuller set for another. Search results have their own view parameter, sysparm_result_view, which controls the layout used when the results come from a search rather than a list.

Exporting in a file format

The address can also request a file instead of a page. The format is named with an encoded ampersand followed by the format name, written as %26 and then the name. The supported formats are CSV, XML, PDF and UNL, the last being the unload format. Combined with a sysparm_query, the file is limited to the matching records.

Building a query from a list filter

The platform can generate the encoded string for you. Open a list, build a filter, and click Run. Then right-click the end of the filter breadcrumb and choose Copy query. The string goes to your clipboard and can be pasted into a URL query or into a reference qualifier.

The string uses plain encoded query syntax, so a filter on active records with impact 1 or 2 reads active=true^impact=1^ORimpact=2, and it can be appended to a list address after sysparm_query=.

Presetting catalog variables with sysparm_variable_values

Catalog items use a separate parameter for prefill. The sysparm_variable_values parameter takes a JSON-style object of key-value pairs. Each key is a variable name and each value is the value to set. Pairs are separated by commas, and each key is separated from its value by a colon. A reference variable needs the sys_id of the target record as its value, not the display name.

The feature is on by default and can be turned off for the whole instance with a system property. Portal widget instances also carry a Disable URL prefill option, which is unchecked by default and turns prefill off for that one portal.

The same idea is handled differently in other interfaces. In the Next Experience UIs, the pairs are passed through the variableValues property on the catalog item macroponent in UI Builder. In Virtual Agent inline catalog items, the same property takes the pairs as a stringified JSON object.

Some variable types cannot be prefilled. These are attachment, custom, custom with label, the non-input types label and container, masked, UI page, and multi-row variable sets. Values fill in the order the variables are defined on the form. Prefilled values count as if a user typed them, so catalog UI policies and client scripts still run after the values are set.

Scripting URLs with the GlideURI object

Server-side scripts can read and change the parameters of a URL through a GlideURI object. A global script gets one from the action object, while a scoped script creates one with new GlideURI(). The main methods are:

Method Purpose
get Reads a parameter value by name
set Sets a parameter name and value
getMap Returns all query parameters as key-value pairs
setView Adds a view name as the sysparm_view parameter
deleteParameter Removes one named parameter
deleteMatchingParameter Removes parameters whose name begins with a given string
getFileFromPath Returns the file name part of the address
toString Rebuilds the URI string and applies URL encoding to characters that are not valid in a URL

get, set, getFileFromPath and toString have scoped equivalents, while deleteParameter, deleteMatchingParameter, getMap and setView are not available in scoped applications. toString converts ampersands in the URL to their URL-encoded form. The object should not be used in scripts that run during an export or in background jobs.

Action parameters are a separate set

JSON web service calls use a different family of sysparm parameters. These are sysparm_action, sysparm_sys_id and sysparm_record_count, along with sysparm_query for the action itself. The query applies to the get, getRecords, update and deleteMultiple actions. A view on get and getRecords limits the fields returned to those in the view, including referenced values. If the view name is missing or invalid, all fields marked active in the dictionary come back instead.

Output for reference fields is controlled by displayvalue. Its default is false, which returns sys_ids alone. Setting it to true returns display values alone, and setting it to all returns both. The displayvariables flag, set to true on get or getRecords calls, returns the variables attached to a record. The record count is capped by a system property that limits the rows any single call can retrieve.

Long links and tiny URLs

A generated address can grow long once several parameters are added. A very long address can fail to open, which is the case the tiny URL setting exists to handle. Tiny URL support shortens some of the redirect addresses the platform generates once they pass a length threshold. A record opened directly keeps its full address.

Email notifications use a base address of their own. The glide.email.override.url property sets a custom base address for those links, so links in notifications point to the address you choose rather than the default instance address.

Frequently asked questions

Can a link open a new form already filled in?

Yes. Set the sys_id to -1 and pass field=value pairs in sysparm_query. The values are applied to the new record when the form opens.

What is the difference between a query on a list and a query on a form?

On a list, sysparm_query filters the records shown. On a new form, the same parameter writes its values into the fields of the record being created.

How do I get a long, correctly encoded filter into a link?

Build the filter on a list, run it, and use Copy query on the filter breadcrumb. Paste the result into the URL. The copied string already holds the conditions in encoded query syntax, so nothing needs retyping.

Can I preset a catalog request?

Yes, with sysparm_variable_values. Use variable names as keys and the values as the content. Attachments, masked variables, UI pages and multi-row variable sets cannot be prefilled this way.

Why did my catalog values not appear?

Prefill is on by default, but it can be turned off at the instance level or for a specific portal widget. The variable type may also be one of the unsupported types.

Can scripts change URL parameters?

Yes. A GlideURI object provides get, set, getMap, setView and several deletion methods. Some methods are not available in scoped applications, and the object should stay out of export and background-job scripts.