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

Anurag Tripathi
Mega Patron
Mega Patron

MAke sure its a v2 list and not v3 only

-Anurag

Hi, yes it is set as v2 list, most of the settings areOOTB, I only changed the script, set it to client, and set it as a List UI Action.

James Asbury
Kilo Contributor

The problem with this is that the code is not encapsulated in a function, and there is no function called in the field 'onClick'.

Ramesh Kandhan
Tera Contributor

Hi James,

 

g_list is client side object.

1.you must enable to client

2.create onclick function

find_real_file.png