Getting Related List Display names

chidanandadhath
Kilo Guru

I want to get the display name of "related list" in a form, i have the below script where I'm getting in a table.cmdb_ci format..is there any other table which I can directly refer?

gr.addQuery('name','cmdb_ci_win_server');
gr.addQuery('view.title','Default View');
gr.query();
while(gr.next())
{

var strListId = gr.sys_id;

var grRelatedListEntry = new GlideRecord('sys_ui_related_list_entry');
grRelatedListEntry.addQuery('list_id',strListId);
grRelatedListEntry.query();
while(grRelatedListEntry.next())
{
gs.print(grRelatedListEntry.related_list);
}

}

 

4 REPLIES 4

Mike Patel
Tera Sage

instead of gs.print(grRelatedListEntry.related_list);

use

gs.print(grRelatedListEntry.list_id.getDisplayValue());

 

If that's not what you are looking then are you looking for Table name?

I want related list names like 'Network adapter' instead of "

cmdb_ci_network_adapter.cmdb_ci"

below is the output I'm getting for the code
*** Script: cmdb_ci_win_server,Related List,cmdb_ci_network_adapter.cmdb_ci,0
cmdb_ci_win_server,Related List,cmdb_ci_storage_hba.computer,1
cmdb_ci_win_server,Related List,cmdb_ci_storage_device.computer,2
cmdb_ci_win_server,Related List,cmdb_ci_file_system.computer,3
cmdb_ci_win_server,Related List,cmdb_software_instance.installed_on,4
cmdb_ci_win_server,Related List,cmdb_running_process.computer,5
cmdb_ci_win_server,Related List,cmdb_serial_number.cmdb_ci,6
cmdb_ci_win_server,Related List,REL:80a164460ab30152004422b3fb69ca1e,7
cmdb_ci_win_server,Related List,REL:8203b8b30ab301520035533a59ed530f,8
cmdb_ci_win_server,Related List,cmdb_ci_memory_module.cmdb_ci,9
cmdb_ci_win_server,Related List,cmdb_tcp.computer,10
cmdb_ci_win_server,Related List,cmdb_ci_config_file_tracked.related_ci,11

Jaspal Singh
Mega Patron
Mega Patron

Replace 

gs.print(grRelatedListEntry.related_list);

with

gs.print(grRelatedListEntry.label_id);

sachin_namjoshi
Kilo Patron
Kilo Patron

use below code

 

gr.addQuery('name','cmdb_ci_win_server');
gr.addQuery('view.title','Default View');
gr.query();
while(gr.next())
{

var strListId = gr.sys_id;

var grRelatedListEntry = new GlideRecord('sys_ui_related_list');
grRelatedListEntry.addQuery('list_id',strListId);
grRelatedListEntry.query();
while(grRelatedListEntry.next())
{
gs.print(grRelatedListEntry.name);
}

}