Need help in UI action button script for Configurable Workspace

Jithender1
Tera Contributor

Hello,

 

we have created a button on platform UI which will call script include.

need the same to replicate in workspace but unable to do so.

 

UI action script for platform ui:

 

function onClick() {

    var additionalusers = g_form.getValue('additional_affected_user_required');
    //var affectedusers = g_form.getValue('additional_affected_user');

    if (additionalusers == 'false') {
        alert("Alert : this is test");
        return;
    }
    var gm = new GlideModal("glide_confirm_basic", true, 600);
    gm.setTitle("Disable Confirmation");
    gm.setPreference("title", " Warning : .Are you sure you want to disable their accounts?");
   
    gm.setPreference("onPromptComplete", function() {
        alert('clicked ok');
        gsftSubmit(null, g_form.getFormElement(), 'demo_user');
        var ga = new GlideAjax('Disable_User');
        ga.addParam('sysparm_name', 'updateAccount');
        ga.addParam('sysparm_incident_id', g_form.getUniqueValue());
        ga.getXMLAnswer(function(response) {
            
            gsftSubmit(null, g_form.getFormElement(), 'demo_user');
           
        });
    });

    gm.setPreference("onPromptCancel", function() {
        alert("You clicked on 'Cancel'");
    });
    gm.render();
}
 
Need same functionality in workspace button as well. Please help.
 
Note: confirm() method is not working in our environment, please use glide_modal_confirm as above.
 
2 REPLIES 2

Diogo Ramos
Giga Sage

Hello, have you looked at the following article https://www.servicenow.com/community/next-experience-articles/how-to-use-ui-actions-in-workspaces/ta... ?

Normally this has enough information to fix your issue. You can also see an out of the box UI action (Report Knowledge Gap) that uses confirm modals and glideAjax : https://<YOURINSTANCE>.service-now.com/nav_to.do?uri=sys_ui_action.do?sys_id=d74f5f3a532230104088ddeeff7b1241.

I Hope it helps.

Ankur Bawiskar
Tera Patron
Tera Patron

@Jithender1 

for your UI action to work in workspace, you need to write the script in workspace client script

there are many OOB UI actions where you will find use of g_modal with confirm in workspace client script

Did you check that?

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

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