Getting Current is not defined

NaveenKumarSN
Tera Expert

Screenshot.png

HI,

I have created one UI action test step  and while executing test step it got failed with current is not defined.

 

 

4 REPLIES 4

Sheldon  Swift
ServiceNow Employee
ServiceNow Employee

Hi @NaveenKumarSN - Have you tried clicking the UI manually and looking for errors? It might be helpful if you post the UI action script here.

NaveenKumarSN
Tera Expert

Yes manually its working as expected while automating getting current is not defined

 

/**
 
* Description: UI Action to check for necesarry prerequisites before moving to Review State
 
* Parameters: NA
 
* Returns: Submits the AC for approval and moves the workflow to Review
*/

function send_for_approval() {
    if (g_user.hasRole("x_abc_def.admin") == false) {
        var reason = g_form.getValue('reason_selected');
        if (reason == '' || reason == 'false') {
            var ga = new GlideAjax('AutomationUtils');
            ga.addParam('sysparm_name', 'getTestCount');
            ga.addParam('sysparm_sys_id', g_form.getUniqueValue());
            ga.getXML(testCount);

            var answer = 'false';
        } else {
            gsftSubmit(null, g_form.getFormElement(), 'approval');
        }

        function testCount(response) {


            answer = response.responseXML.documentElement.getAttribute("answer");
            if (answer < 3) {
                g_form.addErrorMessage('Please execute atleast 3 successful tests to send this case for approval. Currently, only ' + answer + ' successful tests have been conducted since the case moved from the draft state.');
                return false; //Abort submission

            }
            gsftSubmit(null, g_form.getFormElement(), 'approval');
        }

        sendApproval();
    } else {
        gsftSubmit(null, g_form.getFormElement(), 'approval');
        sendApproval();
    }
}

if (typeof window == 'undefined')
    sendApproval();

function sendApproval() {
    if (current.application.supported_by != '' && current.advance == false) { // if the automation case is not advanced and application is filled
        current.approval_state = 'review';
        current.active = false;
        current.update();
    } else if (current.advance == true && new x_inmpl_automation.AutomationUtilsServer().getAPIConfigurationSupportedBy(current.getValue('sys_id'))) { // if advanced is true..
        current.approval_state = 'review';
        current.active = false;
        current.update();
    } else {
        current.setAbortAction(true);
        gs.addErrorMessage("Application's supported by user is required to send approval");
    }

    action.setRedirectURL(current);
}

Working as expected does not necessarily mean there are no errors. Are you able to post the script?

Shared in previous post