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.

List UI Actions get Query form list view

Community Alums
Not applicable

My requirement is to get query:

AbdulKhader_0-1721963119214.png

 

I tried g_list.getQuery() is not working:

My Script:

function approve() {


    if (g_list && g_list.getChecked() == '') {
        var query = g_list.getQuery()

        var gaCount = new GlideAjax('global.SchedMaintQueueUtil');
        gaCount.addParam('sysparm_name', 'getPendingRecCount');
        gaCount.addParam('sysparm_query', query);
        gaCount.getXMLAnswer(getCountApprove);
    } else {

        var selSysIds = g_list.getChecked();
        var sysIdList = selSysIds.split(',');
        if (selSysIds) {
            var gaCountSys = new GlideAjax('global.SchedUtil');
            gaCountSys.addParam('sysparm_name', 'getPending');
            gaCountSys.addParam('sysparm_sys_ids', sysIdList);
            gaCountSys.getXMLAnswer(getCountApproveSys);
        }
    }
}

function getCountApproveSys(response) {
    var selSysIds = g_list.getChecked();
    var sysIdList = selSysIds.split(',');
    var answer = confirm('You are ' + response + ' records. To proceed click "Ok"');
    if (answer == true) {
        for (var i = 0; i < sysIdList.length; i++) {
            var ga = new GlideAjax('global.SchedUtil');
            ga.addParam('sysparm_name', 'approve');
            ga.addParam('sysparm_sys_ids', sysIdList[i]);
            ga.getXMLAnswer(getRequiredIncApprove);
        }
    } else {
        return false;
    }
}

function getCountApprove(response) {
    var answer = confirm('You are' + response + ' records. To proceed click "Ok"');
    if (answer == true) {
        var ga = new GlideAjax('global.SchedUtil');
        ga.addParam('sysparm_name', 'approveRecord');
        ga.getXMLAnswer(getRequiredIncApprove);

    } else {
        return false;
    }
}


function getRequiredIncApprove(response) {
    location.reload(true);
}
2 REPLIES 2

SN_Learn
Kilo Patron
Kilo Patron

Hi @Community Alums ,

 

Check the below post, this might help:

 

https://www.servicenow.com/community/developer-forum/how-to-get-full-query-from-a-defined-related-list/td-p/2479637 

 

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

Community Alums
Not applicable

Not Related list query