UI Macros

UI macros define modular, reusable components in the ServiceNow platform. For example, UI Macros are used to apply formatters to various forms within ServiceNow that provide additional information about the form without using a field. This functionality requires the knowledge of Jelly script.

To administer UI macros, navigate to System UI > UI Macros and define the following information:

  • 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.

Examples

UI Macros can invoke other UI Macros. In this example, the UI Macro invokes the ui_update_set_picker and ui_timezone_changer macros:

<?xml version= "1.0" encoding="utf-8"&nbsp;?>
<j:jelly trim= "false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
  <g:ui_update_set_picker />
  <g:ui_timezone_changer />
</j:jelly>

UI Macros can be invoked from UI Pages:

<g:macro_invoke macro="decorate_welcome_header_stripe_left" />