Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

UI Action Workspace Client Script

Harshad0405
Tera Contributor

Im working on a Generate PDF Requirement the UI Action I created is working on the Backend for default view and workspace view, but in the FSM/CSM Workspace it is not working 

this is code in the UI ACtion:-

function previewDocument(){
    var sysId = typeof rowSysId == 'undefined' || rowSysId == null ?
        gel('sys_uniqueValue').value : rowSysId;


    // Get Task Document Template associated with current form
    var ga = new GlideAjax("global.TaskUtilsAjax");
    ga.addParam('sysparm_name', 'ajaxFunction_getTaskDocumentTemplate');  // method name
    ga.addParam('sysparm_table_name', g_form.getTableName());
    ga.addParam('sysparm_rec_sys_id', g_form.getUniqueValue());
    ga.getXML(ParseTaskDocumentTemplate);

    function ParseTaskDocumentTemplate(response) {
        var answer = response.responseXML.documentElement.getAttribute("answer");
       
        // If none, stop processing code and show error message
        if (answer == '') {
            g_form.addErrorMessage(getMessage('Task Document Template must be defaulted or selected first'));
            return;
        }


        // Prompt PDF Preview Screen
        var dialogClass = GlideModal ? GlideModal : GlideDialogWindow;
        var dialog = new dialogClass('Preview task document dialog');
        dialog.setTitle(getMessage('Preview Document'));

        dialog.setPreference('sysparm_sysId', sysId);
        dialog.setPreference('sysparm_tableName', g_form.getTableName());
        dialog.setPreference('sysparm_targetTable', g_form.getTableName());
        dialog.setPreference('sysparm_targetId', sysId);
        dialog.setPreference('sysparm_scriptName', 'global.TaskUtilsAjax');
        dialog.setPreference('sysparm_edit', 'false');
        dialog.setPreference('sysparm_sign', 'false');
        dialog.setPreference('sysparm_generate_document', 'true');
        dialog.setPreference('sysparm_pdfTemplateTableName', 'u_task_document_template');
        dialog.setPreference('sysparm_pdfTemplateSysId', answer);

        dialog.render();
    }
}
I need solution to write Workspace Client Script


1 REPLY 1

Raya1
Tera Contributor

Have you resolved this problem, I am facing the same 🙂