Create a UI macro for a formatter
Create a UI macro to define the content that the formatter displays.
Before you begin
This functionality requires knowledge of Jelly script.
Role required: ui_macro_admin
Procedure
-
Navigate to All > System UI > UI Macros.
-
Click New.
-
Complete the form.
-
In the XML script field, enter Jelly script to define the content to be displayed by the formatter.
Note: The UI Macro for the formatter represents a row in the UI. It must begin and end with
<TR></TR>tags.[Omitted image "FormatterUIMacro.png"] Alt text: Formatter UI macro
This Jelly script is reproduced below in plain text that you can copy into the Macro form as a basis for your macro script.
XML<?xml version="1.0" encoding="utf-8" ?><j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null"><button style="background: #C0C0C0; border-color: darkgrey; color: #3f464f; height:30; width:70"onclick="saveCustomAttachment();return false"><b>Attach file</b></button><script>function saveCustomAttachment(){var tableName = g_form.getTableName();var sys_id_input = gel('sysparm_item_guid') ? gel('sysparm_item_guid').value : g_form.getUniqueValue();if(tableName === "ni"){saveCatAttachment(sys_id_input, 'sc_cart_item');}else{saveAttachment('sc_req_item', sys_id_input);}}</script></j:jelly> -
Click Submit.
Parent Topic:Using formatters
Related topics
Create a formatter and add it to a form
Limit the number of activity stream entries
---
title: Create a UI macro for a formatter
description: Create a UI macro to define the content that the formatter displays.
locale: en-US
canonical_url: https://www.servicenow.com/docs/r/australia/platform-administration/t\_CreateAUIMacro.html
release: australia
topic_type: task
last_updated: "2026-09-10"
reading_time_minutes: 2
breadcrumb: [Formatters, Administer, Form administration, Forms, fields, and lists, Configure core features, Administer the ServiceNow AI Platform]
---
# Create a UI macro for a formatter
Create a UI macro to define the content that the formatter displays.
## Before you begin
This functionality requires knowledge of Jelly script.
Role required: ui\_macro\_admin
## Procedure
1. Navigate to **All** > **System UI** > **UI Macros**.
2. Click **New**.
3. Complete the form.
4. In the **XML** script field, enter Jelly script to define the content to be displayed by the formatter.
**Note:** The UI Macro for the formatter represents a row in the UI. It must begin and end with `<TR></TR>` tags.
\[Omitted image "FormatterUIMacro.png"\] Alt text: Formatter UI macro
This Jelly script is reproduced below in plain text that you can copy into the Macro form as a basis for your macro script.
```
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<button style="background: #C0C0C0; border-color: darkgrey; color: #3f464f; height:30; width:70"
onclick="saveCustomAttachment();return false">
<b>Attach file</b>
</button>
<script>
function saveCustomAttachment(){
var tableName = g_form.getTableName();
var sys_id_input = gel('sysparm_item_guid') ? gel('sysparm_item_guid').value : g_form.getUniqueValue();
if(tableName === "ni"){
saveCatAttachment(sys_id_input, 'sc_cart_item');
}else{
saveAttachment('sc_req_item', sys_id_input);
}
}
</script>
</j:jelly>
```
5. Click **Submit**.
**Parent Topic:**[Using formatters](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/platform-administration/c_Formatters.md)
**Related topics**
[Activity formatter]()
[Create a formatter and add it to a form]()
[Process flow formatter]()
[Parent breadcrumbs formatter]()
[Approval summarizer formatter]()
[Limit the number of activity stream entries]()
[Override a formatter with macros]()
[Jelly tags](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/api-reference/scripts/r_JellyTags.md)
| title | Create a UI macro for a formatter |
| description | Create a UI macro to define the content that the formatter displays. |
| locale | en-US |
| canonical_url | https://www.servicenow.com/docs/r/australia/platform-administration/t\_CreateAUIMacro.html |
| release | australia |
| topic_type | task |
| last_updated | 2026-09-10 |
| reading_time_minutes | 2 |
| breadcrumb | FormattersAdministerForm administrationFormsfieldsand listsConfigure core featuresAdminister the ServiceNow AI Platform |