UI Action - Workspace client script not working

angel7170
Tera Contributor

Hi - I have this UI action - Apply Template to show up both in the native UI as well as in the Service Operations Workspace but in the workspace, the UI action doesn't work. I am missing something in this line of code. Can you please help me with it?

 

When I click on the UI action (Apply Template) it bring the list of templates, but when I select the template, nothing happens. This works in the native UI but not in the Workspace

 

angel7170_0-1750182402077.png

 

This is the script in the Workspace client script

function onClick(g_form) {
    var getTable = g_form.getTableName();
    var getRecord = g_form.isNewRecord().toString();

    function applyTemplate(sTemplateObject) {
        oTemplate = JSON.parse(sTemplateObject);
        applyTemplate(oTemplate.sid);
        g_form.setValue("u_template", oTemplate.sid);
        g_form.addInfoMessage("Template" + oTemplate.name + " has been applied.");
        g_form.submit('apply_template');
    }

    function openPopup() {
        var url = "/applicable_templates.do?sysparm_recordtable=" + getTable + "&sysparm_recordexists=" + getRecord;
        getMessage('Please select a Template', function(msg) {
            g_modal.showFrame({

                title: msg,
                url: url,
                size: 'lg',
                autoCloseOn: 'URL_CHANGED',
                callback: function(ret, data) {
                    if (ret)
                        applyTemplate(data);
                }

            });

        });
    }
    openPopup();
}
0 REPLIES 0