- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2020 03:32 AM
Hi ,
I have few doubts with Scripting
1.How to know How many Reference Fields are present in a Record ?? i have Record sysd_id
and
2.How to know the value of Reference Field in a Record ? Value not , sys_id of field .
My Requirement :
I have a Table:
Schema Table has Refereence Field linked to DataBase Table .
Schema table Record_1 is Linked to Database Table Record_
With Sys_Id of Schema Table Record i want to fetch the Related Record (i.e Database Table Record_1 name )
Thankyou ,
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2020 12:43 AM
here i tested the script, for my incident table, same way you can do it for your table.
var gr = new GlideRecord('incident'); // change the table name
gr.addQuery('sys_id','98e902e02f6b4c10f68d5ff62799b609'); // add record id
gr.query();
gr.next();
var fields = gr.getFields();
for(var i = 0;i<fields.size();i++){
var glideElement = fields.get(i);
if (glideElement.hasValue()) {
if(glideElement.getED().getInternalType() == 'reference'){
gs.print(glideElement.getDisplayValue());
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2020 12:58 AM
You can directly gilde particular table and pass the sys_id of the record
var gr = new GlideRecord('incident'); // table name
gr.get('7f71107c1bb60010445ffcc8cc4bcb3f'); //sys_id of record
gr.query();
if(gr.next())
{
var fields = gr.getFields();
for(var i = 0;i<fields.size();i++){
var glideElement = fields.get(i);
if (glideElement.hasValue()) {
if(glideElement.getED().getInternalType() == 'reference'){
gs.print(glideElement.getDisplayValue());
}
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2020 01:28 AM
Hi,
No errors BUT
Results are bot displaying .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2020 01:45 AM
Its working for me please check your record id is correct or not

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2020 01:48 AM
It's working for me please check your record id whether it is correct or not