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 choice UI action server side unable to call script include

venkat101
Tera Guru

Hi,

I am trying to call script include from list choice ui action and it is not working.

below is my code:

new ITEquipmentUtils().getRITM(g_list.getChecked());
When try above logic, i dont see script include getting triggered. But, if do the same logic and replace passing variable with 'sys_id' string value, script include is triggered. I want to know how to capture the selected row on list view and send to script include.
 
considering above may not work i tried with client side ajax call. and even this is not working.

 

function selectedRecords() {
    var asset_sysID = g_list.getChecked();
    if (!asset_sysID || asset_sysID.length == 0)
        return;

    var assetRITM = new GlideAjax('global.ITEquipmentRequestUtils');
    assetRITM.addParam('sysparm_name', 'assetRITM');
    assetRITM.addparam('sysparm_passet_sysID', asset_sysID);
    assetRITM.getXML(genEmail);
    g_list.refresh(1);
}

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

 

1 ACCEPTED SOLUTION

venkat101
Tera Guru

after changing g_list to current.sys_id it worked.

 

 

var sysID = current.sys_id;

var triggerEmail = new ITEquipmentUtils().getAssetRITM(sysID);

 

View solution in original post

3 REPLIES 3

AnirudhKumar
Mega Sage
g_list is a client side object. It will not work if your UI Action runs as server.
Run your UI Action as client-side, use g_list.getChecked(), get your sysids, then pass it to server

@AnirudhKumar I also tried that. please look at the code for details of that.

venkat101
Tera Guru

after changing g_list to current.sys_id it worked.

 

 

var sysID = current.sys_id;

var triggerEmail = new ITEquipmentUtils().getAssetRITM(sysID);