Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

How to use both client and server side code in declarative action

itsmegk
Tera Contributor

Hey all,

 

I have a ui action(find the code below), which is working as expected. And it contains both server side and client side script. I wish to configure same functionality in workspace as well. So i have decided to go with declarative action.

What type of declarative action i should use and how to use both server and client side script in declarative action.

Ui Action:

function checkList() {
    if (g_list.getChecked() !== '') {
        var ids = g_list.getChecked();
        var ga = new GlideAjax('ComplianceControlStateUpdater');
        ga.addParam("sysparm_name", "updateControlStateAndNotify");
        ga.addParam('sys_id', ids);
        ga.getXML(res);
    }

    function res(response) {
        var answer = response.responseXML.documentElement.getAttribute("answer");
       
    }

    g_list.action('eee0ef221bde921076d6ed74604bcb11', 'group_attest');
}
if (typeof window == 'undefined') {
    server();
}

function server() {
    if (new sn_compliance.ControlRequirementUtils().controlToCRsM2mExistsForQuery({
            "control": current.getUniqueValue(),
            "control_requirement.state": "retired"
        })) {
        gs.addErrorMessage(gs.getMessage('One or more requirement is in retired state.'));
    } else {

        var isList = action.getGlideURI().get('sys_is_list');
        if (!isList) //Not from list form
            action.setRedirectURL(current);
    }
}
0 REPLIES 0