Skip to content
Release: Australia · Updated: 2026-03-12 · Official documentation · View source

UI macros

UI macros are discrete scripted components administrators can add to the user interface.

UI macros are typically controls that provide inputs or information not provided by existing field types. By default, the system provides UI macros for a variety of user interface elements such as:

  • All formatters
  • The Service Catalog cart
  • The action icons next to fields
  • The action icons on forms and lists
  • The widgets of a content management system
  • The Orchestration activity designer

Administrators can create their own UI macros to provide custom controls or interfaces. Creating UI macros requires knowledge of Jelly script. Review the existing UI macros for examples and suggested approaches. Those who want to build custom interfaces with JavaScript technologies should consider Service Portal as an alternative.

Note: To view available UI macros, navigate to All > System UI > UI Macros.

Parent Topic:Creating custom UI Pages and UI macros

Related topics

Service Portal

Create a UI macro for a formatter

UI macro basics

UI macros can be used to build solutions that can’t be built using the available catalog variable types.

Accessible UI macros

Several UI macros are available in the UI macros [ui_macros] table. These UI macros have names starting with ui_ and emulate the behavior of a subset of standard form field types for use in UI pages. For example, the ui_date_time UI macro can act like a glide_date_time field in a UI page, providing a type-able input field with a date/time selector.

A UI macro can be included in a UI page with the <g:> Jelly tag. The following example includes the ui_date_time UI Macro, providing two optional attributes to the UI Macro:

<g:ui_date_time name="due_date" value="2023-11-24 08:30:00" onchange="checkDateValue()" />

The attribute values in the <g:> Jelly tag are provided to the UI macro as jvar-prefixed variables. The UI macro can use the jvar-prefixed variables in its XML.

Attributesjvar-prefixed variables
namejvar_name
valuejvar_value
onchangejvar_onchange

Note: These UI macros aren’t intended to support all features of their corresponding form field type. In many cases, the macros are only intended for specific ServiceNow application use cases.

The ui_-prefixed UI macros include descriptions specifying supported attributes that can (or must) be provided in the UI page's <g:> Jelly tag. To view available UI macros, navigate to All > System UI > UI macros.

/

Custom UI macros

The ui_example UI macro uses three jvar-prefixed variables: jvar_name, jvar_test_attribute and jvar_laptop_type. These variables can be provided to the UI macro as name, test_attribute and laptop_type attributes in a <g:> Jelly tag in a UI page.

  • Creating the ui_example UI macro

    Navigate to All > System UI > UI Macros and select New.

    Name the macro ui_example and add the following script to the XML field:

    <?xml version="1.0" encoding="utf-8" ?>
    <j:jelly trim="true" xmlns:j="jelly:core" xmlns:g="glide">
        <div>name jvar: ${jvar_name}</div>
        <div>test_attribute jvar: ${jvar_test_attribute}</div>
        <div>laptop_type jvar: ${jvar_laptop_type}</div>
    </j:jelly>
    
  • Using the macro in a UI page

    Navigate to All > System UI > UI Pages and select New. You will be asked to select an administrator role.

    Name the UI page and add the following script to the HTML field:

    <?xml version="1.0" encoding="utf-8" ?>
    <j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
        <div style="text-decoration:underline">Template include one:</div>
        <g:ui_example name="Fred Luddy" test_attribute="I am an attribute" laptop_type="ThinkPad" />
        <hr/>
        <div style="text-decoration:underline">Template include two:</div>
        <g:ui_example name="Pat Casey" test_attribute="I am a different attribute" laptop_type="Macbook Pro" />
    </j:jelly>
    
  • Checking output

    In the UI page, you can click Try It to view the results.

Note: If you create a macro and it doesn’t display as expected in the UI page, clearing the cache might help. To clear the cache of your instance, in your browser, enter <server_url>/cache.do.

Related topics

UI pages

Jelly tags

<g:ui_form/>

<g:ui_input_field />

<g:ui_checkbox/>

Calling UI macros

Administrators can call UI macros from certain record types associated with the user interface.

Record typeExample
Dictionary attributeDisplay an icon for a reference field: ``` ref_contributions=ui_macro_name
</td></tr><tr><td>

UI page

</td><td>

Display something on a UI page:

 ```
<g:macro_invoke macro="ui_macro_name" />
UI macroCall a UI macro from another UI macro: ```
</td></tr></tbody>
</table>

## UI macro form

Each UI macro record consists of a name and an XML document written in Jelly code.

|Field|Description|
|-----|-----------|
|Name|A unique and descriptive name for this macro.|
|Active|Select the check box to render the element as defined. Clear the check box to disable the element without deleting the code. For example, the **email\_reply** macro is inactive by default.|
|Description|Describe the purpose of the macro and parameters passed to it.|
|XML|Jelly script that defines the macro.|

## Custom approval UI macro

This section describes how to create a custom approval UI macro.

**Warning:** The customization described here was developed for use in specific instances, and is not supported by Now Support. This method is provided as-is and should be tested thoroughly before implementation. Post all questions and comments regarding this customization to our community [forum](http://community.service-now.com/).

**Script Name**: Custom Approval UI Macro

**Type**: UI Macro

**Description**: Here is an option to get more detail out of the My Approvals view of an Execution Plan. This can be done by creating a new UI macro. Navigate to **System UI** and click **UI Macros**. First, rename the existing `approval_summarizer_sc_task` to something like `approval_summarizer_sc_task_old` and deactivate it. Then create a new one using the same name \(`approval_summarizer_sc_task`\). The name should basically tell you what the macro does and what it applies to. In this case, we're replacing an existing one so we decided to re-use the existing name.

Copy the XML script at the bottom of this article into the XML code window in the new UI macro. This is great way to give some detail to an approver when you are making line item approvals via approval tasks within the Service Catalog Execution Plans.

The following example script has a link into the item ordered, a short description \(which contains the ability to expand the variables from the item\), price, quantity and the total price. This helps the approver in that it shows more detail. They can now see what they are actually approving.
${sc_task.request_item.request.opened_by.getDisplayValue()}
${sc_task.request_item.request.requested_for.getDisplayValue()}
${sc_req_labels.number.sys_meta.label}${sc_req_labels.description.sys_meta.label}${sc_req_labels.price.sys_meta.label}${sc_req_labels.quantity.sys_meta.label}${gs.getMessage('Total')}
${sc_task.request_item.number} ${sc_task.request_item.quantity} ```

sndocs is an independent community mirror and is not affiliated with or endorsed by ServiceNow.

ServiceNow, the ServiceNow logo, Now, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc., in the United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are associated.

© 2026 ServiceNow, Inc. All rights reserved.

Documentation content is redistributed under the Apache License 2.0 from the ServiceNowDocs repository.