
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2018 09:18 AM
Hi guys,
I got a question, there's one coworker who's trying to add some extra functionality to the "Create Change" button on the Vulnerability group form. In that form there's a related list of "vulnerable items" and he's trying to somehow grab what records are selected on that list through a script. I've been researching for a while but have only found information about using g_list.getChecked(), which only works directly on the list. I don't really think there's a way to grab that information as a related list is more of a "view" of an existing list with it's own query.
If you have any suggestions, I'll be thankful to see them ^^
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2018 07:07 AM
We ended up finding a solution. It consisted in capturing the related list in an object so we could use GetChecked() on it by using getByName([related-list-name]).
var list = GlideList2.getByName("relatedListName");
var itemArray = list.getChecked();
itemArray would contain sys_ids of the selected items.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2018 03:10 PM
So the behavior would be that someone would scroll down to the list, check a bunch of items, then scroll back up and use the Create Change button? I think you're right that it would be difficult to get the checked items on the related list from the change button. You could instead run a ui action on that list that could access the checked boxes directly, or create some sort of popup when they hit create change where they can select the vulnerable items.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2018 07:07 AM
We ended up finding a solution. It consisted in capturing the related list in an object so we could use GetChecked() on it by using getByName([related-list-name]).
var list = GlideList2.getByName("relatedListName");
var itemArray = list.getChecked();
itemArray would contain sys_ids of the selected items.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2021 09:25 AM
Hi Ivar,
I have tried to get the selected records from a related list using the following script:
function test() {
alert(g_form.getRelatedListNames());
try {
var list = GlideList2.getByName('REL:95ba1bf51bf0bc10fccfa9f6624bcbcb_list');
alert(list);
var itemArray = list.getChecked();
alert(JSON.stringify(itemArray));
} catch (ex) {
alert(ex);
}
}
But the list is shown as null and I am getting the TypeError: Cannot read property 'getChecked' from null.
And I am also having the doubt about the "relatedListName" used in this. Am I using the correct name.?
If yes, then will you be able to help me on this.?
Thanks,
Kaushal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2024 01:46 AM
Hi Kaushal,
Use the below code: