g_list is undefined
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2018 04:26 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2018 05:06 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2018 05:35 AM
Maybe this is the culprit: https://hi.service-now.com/kb_view.do?sysparm_article=KB0541300
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2018 05:37 AM
Though, I don't know what release you're on, so it may not be. This looks to only apply to D, E & F.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2018 05:08 AM
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.