g_list is undefined

James Asbury
Kilo Contributor

Hi ServiceNow community,

I was trying out a custom UI action (list ui, set to client side), when I tried scripting it. More specifically, I am trying to get the list of checked items using g_list.

I tried to use g_list, but it keeps telling me g_list is undefined. Am I doing something wrong?

Here is my code that will alert on an error: (note that I have not configured it to refresh the page automatically and I still have to refresh it manually for now after click the list UI action)

/*jshint esnext: true */
try{
	const selected = g_list.getChecked();
	alert(selected);
} catch(err) {
	alert(err.message);
}

Thank you.

8 REPLIES 8

Hi @rameshanjalai

Yes, thank you, the problem was the onClick function. It confused me at first because you do not need to provide onClick if it is a server-side script. When you check the client box then you get the option to put the onClick.

erik_brostrom
Mega Guru

Maybe this is the culprit: https://hi.service-now.com/kb_view.do?sysparm_article=KB0541300

Though, I don't know what release you're on, so it may not be. This looks to only apply to D, E & F.

Thanks, I wish there were steps to reproduce on the page there. The solution for me was that I needed to provide the onClick method, since it's a client script.