If you want to get the reference table for a ServiceNow list field, perhaps to reformat the data, the below functions usually work:
glideRecord.getElement(fieldName).getED().reference;
However sometimes getElement doesn’t work as was the case recently for me in a client callable scoped script include. In this situation, I had to rig up my own function, which looked like this
getFieldProperties: function(tableName, fieldName) {
var dictGR = new GlideRecord("sys_dictionary");
dictGR.addQuery('name', tableName);
dictGR.addQuery('element', fieldName);
dictGR.setLimit(1);
dictGR.query();
if (dictGR.next()) {
var results = {};
results.fieldName = fieldName;
results.referenceTable = dictGR.getValue('reference');
results.type = dictGR.internal_type.name.getDisplayValue();
return results;
} else {
var results = {};
results.fieldName = fieldName;
results.referenceTable = '';
results.type = '';
return results;
}
}