How to call UI action on a form section using UI macro

sath
Tera Expert

Hi,

We have a UI action that is displayed a link under related links on the form. But user wants that link to be displayed on a section with the form. So, want to call this UI action using UI macro and formatter onto the form section. Please assist on how to call UI action through UI macro.

Here's the UI action code (when user clicks on the link, it returns name/value pair type):

This triggers on click of manageLocation()

 

function manageLocation(){
    var label = getMessage("Manage Location");
    var sys_id = g_form.getUniqueValue();
    var loc = g_form.getValue('u_location');
    if(loc) {
         loc = JSON.parse(g_form.getValue('u_location'));
      }
    var arr = [ ];
    Objects.keys(loc).forEach(function(key) {
          arr.push(key + ': : :' + loc[key]);
   });

   var dialogClass = GlideModal ? GlideModal : GlideDialogWindow;
   var dd = new dialogClass('sn_apm_location');
   dd.setPreference('sysparm_sys_id_ba', sys_id + ' ');
   dd.setPreference('sysparm_loc', arr.toString());

  dd.setTitle(title);
  dd.setWidth(500);
  dd.render();
}

 

 

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

@sath 

you can directly call the UI page from UI macro

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

Hi @Ankur Bawiskar , I'm trying to call UI action through UI macro onto the form. Can you please help with the process?

@sath 

try using this in UI macro <script> tag

g_form.submit(actionName); // give the ui action action name here

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