The CreatorCon Call for Content is officially open! Get started here.

Create a button 'ADD' on the form using ui macros.

priya2023
Tera Contributor

  In my custom application I want to create a button ADD on the field caller, using Ui macros. please provide step by step way to create the action with xml .

11 REPLIES 11

@priya2023 

what do you mean by Add/remove on reference field?

you can use onChange client script or UI policy to show/hide field based on another field

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi sir,

Actually, I created a custom application. In that I configured a reference field 'Approved By'. When I select an user I need to auto populate the user email also. I achieved this requirement by dot walking. And the task is to create buttons  ADD and REMOVE on the reference field. A new user field has to create  by click on the button ADD.

priya2023_0-1685346167516.png

Note:  can we achieve this requirement using Ui macros. If, Please help me in this requirement.

 

 

 

@priya2023 

but why to do this when you already have fields to show dot walked data?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Step1: creating a Custom application.

Step2: Configure a ref field(approved By) and email Field make to auto populate.

Step3: Create Buttons ADD and REMOVE. when we click on ADD button need to get the users list. and from the user list we can select required users. In the same way reverse action for REMOVE button(to remove the users).Using Ui macros can we achieve the requirement?

Markus Kraus
Kilo Sage

If you want to add a Button next to a reference icon, I'd suggest you to use the ref_contributions attribute.

If instead, you want to have the Button on a separate column/row, you should do the following:

1.) Create a UI Macro (sys_ui_macro) and add a simple <button>CLICKME</button> to get started
2.) Create a UI Formatter (sys_ui_formatter), which references the UI Macro you just created
3.) Customize the Form you want to have the Button on, and add the UI Formatter there.

 

Example:

1.) UI Marco Example:

MarkusKraus_3-1685371233901.png

 

 

2.) UI Formatter Example:

MarkusKraus_4-1685371267427.png

 

3.) Add it to the form (task form for demo):

MarkusKraus_6-1685371353435.png

 

Example:

MarkusKraus_5-1685371313510.png