Types of variables

ServiceNow provides a set of 26 variable types.

The Service Catalog supports several types of variables, which are also referred to as questions. Some variable types accept variable attributes. You can also attach help text to any service catalog variable.

Refer to each variable for more information:

The following table shows the UI policy that does not apply to the variable/s listed against it.

Table 1. UI policy and variables
UI policy Variable
Mandatory Break, Container Start, Container End, Container Split, Label, Macro, Macro with Label, UI Page
Read only Break, Container Start, Container End, Container Split, Label, Macro, Macro with Label, UI Page
Visible Break, Container End, Container Split
Show Attributes When Type is One of Certain Values Macro, Macro with Label

Break

Displays a horizontal line across the form. Breaks are formatting elements. No data is collected.

The break variable is not yet supported on service portal and mobile devices.

Figure 1. Example of a break variable
Example of a break variable

Check box

Creates a check box to enable/disable options by selecting/clearing it. List check boxes in order under a label to create a multi-option question (as shown in the figure).

The Required Checked option for the check box validates for a compulsory checked value. For example, an agreement form always requires the check box to be checked before submit. If you submit the form without a selected check box, an alert message is displayed to fulfill the request.

Consecutive check box variables are automatically grouped under an Options label. If you want to define a label of your own, then group check boxes under a label variable. The default Options label is replaced with the label variable.

Points to remember:
  • Asterisk (*) displayed next to the label for check boxes indicates that the entire group is mandatory.
  • If any one check box variable in a group is marked as 'required', the entire group becomes mandatory.
  • If the only 'required' check box in a group is made invisible using a client script or UI policy, then the group is no longer mandatory.
  • Hiding the label hides the entire check box group.
Figure 2. Example of a check box variable
Example of a check box variable

The following video provides more information on the check box variable:

Container start, container split, container end

All three variables are used to define a layout for a container that can hold more variables. Use container start and container end variables to define the start and end points of a container layout. The container end must be used along with container start to close a container.

A container layout can be split into two or three columns using the container split variable. By default, the split is calculated at the 50% mark.

A container is similar to a variable set. Unlike a variable set, containers can be used anywhere (including inside a variable set) and can be nested (a container inside a container). Refer to KB0539982 for more information on using container variables.

To reproduce the container format as shown in the figure, do the following in the container start variable:
  • Select a Layout with 2 Columns Wide, alternating sides.
  • Select the check box for Display title to use a collapsible title bar.

The container variables are not yet supported on service portal and mobile devices.

Figure 3. Example of a container variable
Example of a container variable

Date

Creates a date input widget to display a date value.

Figure 4. Example of a date variable
Example of a date variable

Date and time

Creates a date and time input widget to display both date and time values. Time value is stored in Greenwich Mean Time (GMT) and displayed in the time zone of the current user.

Figure 5. Example of a date and time variable
Example of a date and time variable

Email

Creates an email input widget. Accepts only valid email expressions containing @ and domain information.

The email variable is not yet supported on service portal and mobile devices.

Figure 6. Example of an email variable
Example of an email variable

HTML

HTML variables are useful for providing more content for an item that requires more advanced formatting, including images.

The variable can be:
  • Used for user input.
  • Used for reusable content when put into a variable set (for example, terms and conditions).
  • Available in two modes: Edit and Read-only. In edit mode, a toolbar is available, and links do not work. In read-only mode, no toolbar is available, and links work. To switch between modes, use entitlements or create a UI policy to set the HTML field to read-only mode.
Attention: HTML variables are not supported for display on the shopping cart summary or approval summary screens. If the type is 'HTML', the available in summaries field is hidden in the variable form.

The HTML variable is not yet supported on service portal and mobile devices.

Figure 7. Example of an HTML variable
Example of an HTML variable

Label

Displays a label across the form. Labels are formatting elements. No data is collected.

Tip: You can use labels to arrange questions into sections. Use labels to create a multi-option question (for example, using check boxes).
Figure 8. Example of a label variable
Example of a label variable

List collector

Uses the list collector slushbucket interface to add multiple records from a table.

The list collector variable is not yet supported on service portal and mobile devices.

Figure 9. Example of a list collector variable
Example of a list collector variable

The following video provides more information on the list collector variable:

Note: Reference Qualifier and glide_list attribute applies to releases from Helsinki onward only. It does not apply to Geneva.

Lookup multiple choice

Creates radio buttons using data from a table. Functionality is similar to lookup select box, which creates a choice list from queried data.

The lookup multiple choice variable is not yet supported on service portal and mobile devices.

Figure 10. Example of a lookup multiple choice variable
Example of a lookup multiple choice variable

Lookup select box

Creates a choice list using data queried from a table. Functionality is similar to lookup multiple choice, which creates radio buttons from queried data.

To create the lookup select box shown in the figure, enter the following values:
  • Lookup from table: Incident [incident]
  • Lookup value field: Sys ID
  • Lookup label field: number, category, priority
  • Reference qual: caller_id=javascript:gs.getUserID()^active=true

The lookup select box variable is not yet supported on service portal and mobile devices.

Figure 11. Example of a lookup select box variable
Example of a lookup select box variable

Macro

Inserts a UI macro into the catalog item.

UI macros in the service catalog do not support the following glide_list functions: clickthrough, slushbucket editing, and email field.

Attention: Use phase one Jelly only for any UI macros added as variables. Phase two Jelly within the macro is not processed and appears on the page as standard content.

The macro variable is not yet supported on service portal and mobile devices.

Figure 12. Example of a macro variable
Example of a macro variable

Macro with label

Inserts a UI macro with a label.

The macro with label variable is not yet supported on service portal and mobile devices.

Figure 13. Example of a macro with label variable
Example of a macro with label variable

Masked

The masked variable inserts a field that masks text entered by users. Each character entered by users is displayed as an asterisk (*). Use this variable to ask users for sensitive or confidential data such as passwords.

Since a masked variable uses platform encryption using TripleDES, the values for this variable are also encrypted. These values can be decrypted by using current.variables.getDecryptedValue() on RITM, Catalog Task, or any task extension record created using a record producer.

Figure 14. Example of a masked variable
Example of a masked variable

Multi-line text

Creates a multiple line text input widget.

Figure 15. Example of a multi-line text variable
Example of a multi-line text variable

Multiple choice

Creates radio buttons for question choices.

Figure 16. Example of a multiple choice variable
Example of a multiple choice variable

Numeric scale

Creates a horizontal set of radio buttons with numeric options from Scale min to Scale max (a Likert scale).

Figure 17. Example of a numeric scale variable
Example of a numeric scale variable

Reference

References a record in another table. For example, a variable named point_of_contact references the User [sys_user] table.

Keep the following information in mind as you work with reference variables:
  • Reference variables use the auto-complete feature. To ensure that users have enough information, configure the reference lookup list.
  • Reference variables store the sys_id of the selected record (like reference fields). To use the display value in a script, use the same methods as for a reference field.
current.variables.<variable name>.getDisplayValue()
current.variable_pool.<variable name>.getDisplayValue()
Figure 18. Example of a reference variable
Example of a reference variable

Select box

Creates a choice list from pre-defined question choices.

Figure 19. Example of a select box variable
Example of a select box variable

Single-line text

Creates a single-line text input field.

The single-line text variable is not yet supported on service portal and mobile devices.

Figure 20. Example of a single-line text variable
Example of a single-line text variable

UI page

Inserts a UI page into the catalog item.

Attention: Use phase one Jelly only for any UI macros added as variables. Phase two Jelly within the macro is not processed and appears on the page as standard content.

The UI page variable is not yet supported on service portal and mobile devices.

URL

Creates a URL input widget. URLs are validated for the following protocols: HTTP, HTTPS, FTP.

The URL variable is not yet supported on service portal and mobile devices.

Figure 21. Example of a URL variable
Example of a URL variable

Wide single-line text

Creates a single-line text input field that spans the form, allowing for longer input.

The wide single-line text variable is not yet supported on service portal and mobile devices.

Figure 22. Example of a wide single-line text variable
Example of a wide single-line text variable

Yes/No

Creates a choice list with Yes and No as options.

Figure 23. Example of a Yes/No variable
Example of a Yes/No variable

Service portal and mobile support for variables

The service catalog on mobile devices and service portal do not support the following variable types:
  • Break
  • Container variables
  • Email
  • HTML
  • Label
  • List Collector
  • Lookup Multiple Choice
  • Lookup Select Box
  • Macro
  • Macro With Label
  • Masked
  • Single-Line Text
  • UI Page
  • URL
  • Wide Single-Line Text