How to create macro button in servicenow portal form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
I wanted to create a macro button on portal form named as "ADD', and if we click on add button then it should automatically copy the value mentioned in another variable "Description" and add this value in another exiting Multirow variable as a record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
UI macros won't work on portal as it's not supported.
You can use widget and associate it with variable of type Custom and then handle the logic when click copy the value.
see this and enhance
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
32m ago - last edited 24m ago
Hi @VIKAS MISHRA ,
The best way to handle this on the Service Portal is by using a Catalog Client Script tied to a custom “ADD” button. You should use the supported addRow() API for the Multi-Row Variable Set (MRVS).
Here’s a recommended script example:
{ var descriptionValue = g_form.getValue('description_variable_name');
if (!descriptionValue)
{
g_form.showFieldMsg('description_variable_name', 'Description cannot be empty.', 'error');
return;
}
var mrvsControl = g_form.getControl('multi_row_variable_set_name');
var newRow = { 'mrvs_variable_name': descriptionValue // MRVS variable internal name }; mrvsControl.addRow(newRow); // Optional: clear description field after adding g_form.setValue('description_variable_name', '');
}
- Uses addRow() which is officially supported for MRVS
- Simpler, more maintainable code
- Straightforward to implement without building full custom widgets
Useful References
How to Add Widgets to ServiceNow Catalog Variables: A Comprehensive Guide
🎥Video: Add rows to Multi-Row Variable Set with Client Script
Thanks & Regards,
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution so others can benefit as well.