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.

Why Glide Ajax is not Working in the UI Action Workspace Client script

saineha
Tera Contributor

Client script

    var ga = new GlideAjax('sn_customerservice.getAnyBlockingTasks');
    ga.addParam('sysparm_name', 'checkBlockingTasks');
    ga.addParam('sysparm_caseId', g_form.getUniqueValue());

    ga.getXMLAnswer(function(response) {
        if (response) {
            g_form.addErrorMessage('There are blocking tasks so you cannot resolve this');
            return false;
        } else {
            if (g_form.getValue("close_notes") == "" || g_form.getValue("resolution_code") == "") {

                g_form.addErrorMessage(getMessage('To propose a solution, you must select a resolution code and add resolution notes.'));
                return false;
            }
            else{
                g_form.setValue('state',6);
                g_form.save();
            }

        }
    });

Script Include
checkBlockingTasks: function(caseId) {
        var blockGr = new GlideRecord('sn_action_status_blocked_by');
        blockGr.addQuery('blocked_task', caseId);
        blockGr.addQuery('unblocked_on', '');
        blockGr.query();

        if (blockGr.hasNext()) {
            return true;
           
        }
        return false;
    },

Actually here I have to get the blocking tasks message but anything is not happening on form.
Thank you.
3 REPLIES 3

Bhimashankar H
Mega Sage

hi @saineha 

 

Add this.getParameter("sysparam_caseId") in script include to get the parameters and try it.

checkBlockingTasks: function() { // No parameters here!
    var caseId = this.getParameter('sysparm_caseId'); // Retrieve param sent from client
    var blockGr = new GlideRecord('sn_action_status_blocked_by');
    blockGr.addQuery('blocked_task', caseId);
    blockGr.addQuery('unblocked_on', '');
    blockGr.query();

    if (blockGr.hasNext()) {
        return true;
    }
    return false;
},

 

Thanks,
Bhimashankar H

 

-------------------------------------------------------------------------------------------------
If my response points you in the right directions, please consider marking it as 'Helpful' & 'Correct'. Thanks!

 

Hey @saineha ,

 

Did you get chance to review the code snippet given in my previous post.

 

If my response points you in the right directions, please consider marking it as 'Helpful' & 'Correct'. It will help future readers as well having similar kind of questions and close the thread.

Thanks,
Bhimashankar H

Ankur Bawiskar
Tera Patron
Tera Patron

@saineha 

So if it's not working then what debugging did you do?

what's your findings?

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