Blog

Field Trip

Find out if custom fields are being used in your ServiceNow implementation. Take a field trip!

  1. Login as an admin

  2. Elevate Role to security_admin

  3. In Scripts - Background run this statement (Note takes a long time on really customized instances)

fieldTrip();
function fieldTrip() {
	var grDictionary = new GlideRecord('sys_dictionary');
	grDictionary.addEncodedQuery('name=cmdb_ci^elementSTARTSWITHu_');
	grDictionary.query();
	while (grDictionary.next()) {
		var currentTable = grDictionary.name.toString();
		var count = new GlideAggregate(currentTable);
		count.addQuery(grDictionary.element, '!=', '');
		count.addAggregate('COUNT');
		count.query();
		if (count.next()) {
			gs.print('Dictionary name: '+grDictionary.name+', sys_id: '+grDictionary.sys_id+', element: '+grDictionary.element+', count: '+count.getAggregate('COUNT'));
		}
	}
}