Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Get selected items from related list.

Ivar Donado
Mega Sage

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 ^^

1 ACCEPTED SOLUTION

Ivar Donado
Mega Sage

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.

View solution in original post

5 REPLIES 5

Community Alums
Not applicable

Hi Ivar,

 

I have the exact same requirement . I tried using this solution, but it is of no help..The GlideList2.getByName is returning undefined. 
Can you help me with this.