ServiceNow fix script: count all rows in tables

 run the following in background:

 

gs.log('script start','fixScr:hmctsTableCount'); var gr = new GlideRecord('sys_dictionary'); gr.addEncodedQuery('internal_type.label=Collection'); gr.query(); while (gr.next()){ try { var gr1 = new GlideAggregate(gr.name.toString()); gr1.addAggregate('COUNT'); gr1.query(); if (gr1.next()){ gs.log('Table: ' + gr.name.toString() + ' has: ' + gr1.getAggregate('COUNT') + ' records','fixScr:hmctsTableCount'); } } catch (err) { gs.logErro("We've got an error for table: " + gr.name.toString(),"fixScr:hmctsTableCount"); continue; } } gs.log('script end','fixScr:hmctsTableCount');

 

(ServiceNow )

Comments

Popular posts from this blog

GlideRecord setValue

URL link in addInfoMessage