<h2>How to get a list of extended tables for a given table using TableUtils().getTables() API and use the result within GlideRecord?</h2><br/><div style="overflow-x:auto"><article><div ><h3 >Issue </h3><section><ul style="list-style-position: inside;"><li>How to get a list of extended tables for a given table using TableUtils().getTables() API and use the result within GlideRecord?</li><li>Example:</li></ul> <p style="padding-left: 80px;">var tabName = 'sc_req_item';<br />var tu = new TableUtils(tabName);<br />gs.print(tu.getTables());<br />var tbList = tu.getTables();<br /><br />//result is [sc_req_item, task]<br /></p> <ul style="list-style-position: inside;"><li>However, this returns an arraylist (Java) and you are unable to find a way to convert it into a regular array or string so you can use it as follows<br /></li></ul> <p style="padding-left: 80px;">gr = new GlideRecord('sys_dictionary');<br />gr.addQuery('name', ‘IN’, tbList);<br />gr.addQuery('element', 'sys_domain');<br />gr.query();<br />if(gr.next()){<br />//do something<br />}</p></section></div><div ><h3 >Resolution</h3><section><ul style="list-style-position: inside;"><li>You can try something as below to meet your requirement.</li></ul> <p style="padding-left: 80px;">var tabName = 'sc_req_item';<br />var tu = new TableUtils(tabName);<br />gs.print(tu.getTables());<br />var tbList = tu.getTables().toArray();</p> <p style="padding-left: 80px;">for(var i=0;i<tbList.length;i++){<br />gs.print(tbList[i]);<br />var gr = new GlideRecord('sys_dictionary');<br />gr.addQuery('name', 'IN', tbList[i]);<br />gr.query();<br />gs.print(gr.getRowCount());<br />}</p> <p style="padding-left: 80px;">*** Script: Extended tables of sc_req_item are[sc_req_item, task]<br />*** Script: table name : sc_req_item<br />*** Script: Number of records 18<br />*** Script: table name : task<br />*** Script: Number of records 71</p></section></div></article></div>