List context menu - g_list.action doesn't work within a callback function - UI Action

B3N_AU
Tera Guru

Hi,

I have it working when the code looks like this

function confirmApproval() {
	var apprSysId = g_sysId;
	g_list.action('52796e01974031105ca138200153af19', 'appr_list_context', apprSysId);
}

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

function updateAndRedirect() {
    gs.addInfoMessage('made it!!');
}

 

But when I add a callback function. It doesn't work. The alert the line before works

function confirmApproval() {
    var apprSysId = g_sysId;
    var ga = new GlideAjax('Utils');
    ga.addParam('sysparm_name', 'goAndDoSomthing');
    ga.addParam('sysparm_apprSysId', apprSysId);
    ga.getXML(callback);

    function callback(response) {
		alert('This popup works');
		g_list.action('0feb2f0d8748b110245dbae8dabb358b', 'list_context_action', apprSysId);
    //the action sys_id and action name above are correct and if I alert apprSysId I get the right sys_id
    }
}
if (typeof window == 'undefined')
    updateAndRedirect();

function updateAndRedirect() {
   gs.addInfoMessage(this doesn't run');
}

 

Does anyone know why?

 

Don't thing it's a caching issue as I've created it from scratch.

 

Thanks Ben

1 ACCEPTED SOLUTION

Ohh Yes, g_list will not execute server side scripts (during list context)

 

More info: https://www.servicenow.com/community/developer-forum/ui-action-wont-work-as-list-context-menu/m-p/16... 

 

what's the use case here, if you still wanna show message or do some server side logic do it in script include.

something like this:

HemanthM1_0-1689569326894.png

Same output:

HemanthM1_1-1689569381807.png

 

 

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

View solution in original post

6 REPLIES 6

Ohh Yes, g_list will not execute server side scripts (during list context)

 

More info: https://www.servicenow.com/community/developer-forum/ui-action-wont-work-as-list-context-menu/m-p/16... 

 

what's the use case here, if you still wanna show message or do some server side logic do it in script include.

something like this:

HemanthM1_0-1689569326894.png

Same output:

HemanthM1_1-1689569381807.png

 

 

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

The use case is different but I can use the same method

Thanks for confirming what I thought