
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2018 09:03 AM
How to write Background script to display list of records in a specific table for a known system ID.
The table is: core_company
I am guessing it is a Glide Record - Query is what i need to write but cannot identify the correct API to use.
Thanks for your time,
Lon
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2018 09:14 AM
number is not the field defined on core_company table. Try below code:
var gr = new GlideRecord('core_company');
gr.addQuery('sys_id','YourSysId Here');
gr.query();
while(gr.next()){
gs.info(gr.name);
}
Please mark my response as correct and helpful if it helped solved your question.
-Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2018 09:05 AM
Try this
var gr = new GlideRecord('core_company');
gr.addQuery('sys_id','YourSysId Here');
gr.query();
while(gr.next()){
gs.info(gr.number);
}
Please mark my response as correct and helpful if it helped solved your question.
-Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2018 09:10 AM
*** Script: undefined
Does this mean "not found"?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2018 09:14 AM
number is not the field defined on core_company table. Try below code:
var gr = new GlideRecord('core_company');
gr.addQuery('sys_id','YourSysId Here');
gr.query();
while(gr.next()){
gs.info(gr.name);
}
Please mark my response as correct and helpful if it helped solved your question.
-Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2018 09:20 AM
[0:00:00.006] Script completed in scope global: script
But no results are displayed, when I search system wide those files are detected (using code below)
I did not write the below code and do not know how to quickly tailor it to specific table...
//Mystery ID in quotes below
findSysID('your sys ID');
function findSysID(id) {
var gr = new GlideRecord('sys_db_object');
gr.addEncodedQuery('super_class=NULL^nameNOT LIKEts_c_^nameNOT LIKEsysx_^nameNOT LIKEv_');
gr.query();
var searchTable, name;
while (gr.next()) {
name = gr.name + '';
searchTable = new GlideRecord(name);
if (searchTable.isValid()) {
searchTable.addQuery('sys_id', id);
searchTable.queryNoDomain()
searchTable.setLimit(1);
searchTable.query();
if (searchTable.hasNext()) {
gs.print('Found on table: ' + name);
}
}
}
}