Check if a table exists in a server-side script



var gr = new GlideRecord('incident');
gs.info(gr.isValid());

var anotherGr = new GlideRecord('incidentZ');
gs.info(anotherGr.isValid());


https://developer.servicenow.com/app.do#!/api_doc?v=jakarta&id=r_ScopedGlideRecordIsValid 


see https://docs.servicenow.com/bundle/kingston-application-development/page/app-store/dev_portal/API_reference/TableUtils/concept/c_TableUtilsAPI.html

another option:
var table = new TableUtils("cmdb_ci_computer");
gs.print("Does 'my_table' exist? " + table.tableExists()); //--returns true


var table = new TableUtils("cmdb_ci_computerZ");
gs.print("Does 'my_table' exist? " + table.tableExists()); //--returns false


Comments

Popular posts from this blog

Running transform maps asynchronously

Post a command to the ECC queue for the mid server to initiate a powershell file copy

GlideRecord setValue