Retrieve all the Field Names of change_request table

ajith3
Kilo Explorer

The table change_request is used to store the details of all the change requests in service now. I would like to know what are the fields in that table.
Is it possible to get that list by using any functions on GlideRecord api or any api ?

4 REPLIES 4

JonathanJacob
Mega Sage

Take a look at ---

https://wiki.servicenow.com/index.php?title=GlideRecord#getFields



// This can be run in "Scripts - Background" for demonstration purposes

// Get a single incident record
var grINC = new GlideRecord('incident');
grINC.query();
grINC.next();
gs.print('Using ' + grINC.getValue('number'));
gs.print('');

// getFields() returns a Java ArrayList
var fields = grINC.getFields();

// Enumerate GlideElements in the GlideRecord object that have values
gs.print('Enumerating over all fields with values:');
for (var i = 0; i < fields.size(); i++) {
var glideElement = fields.get(i);
if (glideElement.hasValue()) {
gs.print(' ' + glideElement.getName() + '\t' + glideElement);
}
}
gs.print('');

// Get a specific GlideElement: number
gs.print('Getting the number field:');
for (var i = 0; i < fields.size(); i++) {
var glideElement = fields.get(i);
if (glideElement.hasValue() &amp;&amp; glideElement.getName() == 'number') {
gs.print(' ' + glideElement.getName() + '\t' + glideElement);
}
}


randrews
Tera Guru

seems like the easiest way would be to go to system definition/dictionary

filter to the table you want

then export the list to excel if you are looking to provide documentation.


thanks..


ajith3
Kilo Explorer

Thank you .. able to get it..