How to get UI Macros working in Workspace

Jamy1
Tera Guru

In Classic UI, we have places where icons (UI Macro) are next to reference fields. When pressed upon, some action takes place.

In Workspace, the icon doesn't appear and as such, our users are not able to use the functionality that was given by the button. 

The icon button acts as a shortcut to perform certain actions. We'd like to have this icon button next to the field if possible. Is there a way to enable this or an alternative approach?

Example of the icon is attached.

 

7 REPLIES 7

Hi,

As per ServiceNow team it's not possible now.

They might come up with something in later releases.

If my response helped please mark it correct and close the thread so that it benefits future readers.

regards
Ankur

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

Supriya Basak1
Giga Contributor

Hi Jamy,

UI Macro has Jelly content which does not execute in the workspace UI(seismic UI). You can sometimes use action assignments(sys_declarative_action_assignment) for this purpose based on your requirement. You should able to achieve your functionality using this component.

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

 

Regards,

Supriya

MichaelZischeck
Kilo Sage

You can use a Field decorator 

MichaelZischeck_0-1728739954876.png

Here's how it works:

basically it's Client side Javascript. You can, via AJAX, call backend code. But usually you will only get back a few attributes, certainly not a full record.

on the field decorator record you define the table, field and icon to be used

You will then need a web Function  script include (sys_script_include.list)

 

example: fill out primary contact

code on the Field decorator

function onClick() {
    try {
        getAnswer(function(ajaxResult){
g_form.setValue('contact', ajaxResult);
});
    } catch (e) {
        console.log('UIAction->Error' + e);
    }
}
 
function getAnswer(callback) {
    try {
        var ga = new GlideAjax('inc_WebFunctions');
        ga.addParam('sysparm_name', 'getPrimaryContact'); // function to call
        ga.addParam('account', g_form.getValue('account')); // parameter to pass
ga.getXML(function(response) {
            var ajaxResponse = response.responseXML.documentElement.getAttribute('answer');
            callback(ajaxResponse);
        });
 
    } catch (e) {
        console.log('UIAction->Error->' + e);
    }
 
}
 
code in the script include (client callable!)

getPrimaryContact: function() {
var account = this.getParameter('account'); // retrieve passed parameter
var glAccount = GlideRecord('customer_account');
glAccount.get(account);
return glAccount.getValue('primary_contact');
},