- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2023 10:22 PM
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
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2023 09:49 PM
Ohh Yes, g_list will not execute server side scripts (during list context)
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:
Same output:
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2023 01:24 AM - edited ‎07-14-2023 01:26 AM
Hi @B3N_AU ,
If you would like to use call back function and don't want to retrieve whole XML .
replace : ga.getXML(callback); to ga.getXMLAnswer(callback);
working fine:
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2023 10:46 PM
Thanks Hemanth
It still isn't working for me. I must have something set wrong but I can't seem to find it.
Are you able to send through the xml of your working UI Action?
That way I will be able to see where I've gone wrong.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2023 06:14 AM
Hi @B3N_AU ,
i think issue with this line:
var apprSysId = g_sysId;
if you want to fetch the sys_id the selected record here you go
UI action: Make sure you update the action sys_id
function confirmApproval() {
var apprSysId =g_list.getChecked(); //get the sys_id of the clicked record
var ga = new GlideAjax('Utils');
ga.addParam('sysparm_name', 'goAndDoSomthing');
ga.addParam('sysparm_apprSysId', apprSysId);
ga.getXMLAnswer(callback);
function callback(response) {
alert(response);
g_list.action('47e168d1974435101eafb0efe153af25', '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");
}
screenshot :
script include:
Utils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
goAndDoSomthing: function(){
var clicked = this.getParameter('sysparm_apprSysId');
return clicked;
},
type: 'Utils'
});
screenshot:
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2023 02:54 PM
I recreated what you gave me and I can confirm that it works as expected.
You created the UI Action as a List banner button, not as List context menu (mentioned in the question subject)
When I change the type to List context menu, the server side code stops working again.
Would you be able to try it out and see if you get the same?