
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2016 07:32 AM
As I had originally posted here: https://community.servicenow.com/thread/216254
I just found out that if I query the sys_email table with a sys_id, the gr[fieldName].getLabel() breaks the script include.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2016 10:55 AM
I figured out what was breaking it.
if (gr.next())
{
var directURL = (gs.getProperty('glide.servlet.uri') + "nav_to.do?uri=" + tableName + ".do?sys_id=" + sysID);
fields = new GlideRecordUtil().getFields(gr);
for (var i = 0; i < fields.length; i++)
{
fieldName = fields[i];
// WITHOUT THIS IF() STATEMENT,
// THIS SCRIPT WILL **BREAK** BECAUSE
// "sys_table_name" IS NOT A FIELD ON THE sys_email TABLE!!
//
// IF IT'S NOT ON THE TABLE, WHY THE HECK DOES IT FIND IT!!?????
if (fieldName == "sys_table_name")
continue;
recordArray.push({ field_name: fieldName, value: gr.getDisplayValue(fieldName), url: directURL, label: gr[fieldName].getLabel() });
fieldsFound = 'true';
}
if (fieldsFound == 'true')
return (new JSON().encode(recordArray));
else
return "No table fields were found in the GlideRecordUtil().getFields(gr) call";
}
Notice the new if() in my code above.
How the heck does "sys_table_name" get found when it's nowhere on the sys_email table!??

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2016 10:55 AM
I figured out what was breaking it.
if (gr.next())
{
var directURL = (gs.getProperty('glide.servlet.uri') + "nav_to.do?uri=" + tableName + ".do?sys_id=" + sysID);
fields = new GlideRecordUtil().getFields(gr);
for (var i = 0; i < fields.length; i++)
{
fieldName = fields[i];
// WITHOUT THIS IF() STATEMENT,
// THIS SCRIPT WILL **BREAK** BECAUSE
// "sys_table_name" IS NOT A FIELD ON THE sys_email TABLE!!
//
// IF IT'S NOT ON THE TABLE, WHY THE HECK DOES IT FIND IT!!?????
if (fieldName == "sys_table_name")
continue;
recordArray.push({ field_name: fieldName, value: gr.getDisplayValue(fieldName), url: directURL, label: gr[fieldName].getLabel() });
fieldsFound = 'true';
}
if (fieldsFound == 'true')
return (new JSON().encode(recordArray));
else
return "No table fields were found in the GlideRecordUtil().getFields(gr) call";
}
Notice the new if() in my code above.
How the heck does "sys_table_name" get found when it's nowhere on the sys_email table!??