How to create a Formatter and UI macros for a table

Community Alums
Not applicable

We have a requirment that I need to create a formatter name say XYZ and Ui macros for a custom table in custom apps, can anyone please help!

1 REPLY 1

ChrisBurks
Mega Sage

Reference: https://docs.servicenow.com/bundle/xanadu-platform-administration/page/administer/form-administratio...

 

A formatter is a record that points to a UI Macro record.

These records are made in the same way that any other record is made in ServiceNow. You can navigate to each respective table and use the "New" button.

 

ChrisBurks_0-1728565576639.png ChrisBurks_1-1728565627732.png

Steps would be to navigate to the UI Macro table and create the UI Macro with your code.

Then go to the Formatter table and create the formatter record. The formatter record has a field (Formatter) for the name of the macro to associate that formatter with. Put the name of the macro you made in the previous step. The formatter also has a field  (Table) that will be for the table you want the formatter to be associated with. Provide the table name of the desired table. For example if the formatter should display on the incident form use "incident".

 

Example of UI Macro:

ChrisBurks_5-1728566821937.png

 

 

Example of Formatter using above macro :

ChrisBurks_2-1728566123229.png

 

However, this doesn't automatically add it to the table. Now you have to open a record on the desired table and use one of the features such as Configure > Form Layout or Configure > Form Builder to add it to the desired form view.

ChrisBurks_3-1728566387345.png

 

Example of using the Form Layout:
ChrisBurks_4-1728566610987.png