The CreatorCon Call for Content is officially open! Get started here.

Finding empty fields in an table

VigneshMC
Mega Sage

I have an table which contains close to 1000 records and there are about 600 fields in that table.I need to find the fields which are empty for all the records.Can anyone tel me easy/efficient way to do that?

8 REPLIES 8

Kalaiarasan Pus
Giga Sage

600 fields???



What table is that ? You need a list like this record has these fields empty ?


yeah 600 fields, thats an custom table.


As it's not an best practice to have this many fields in an table, we would like to remove the empty one's


So you're trying to find out what columns on that table are empty for ALL of its records... so that you can remove the column? Don't even try it, it's not a safe idea to remove a column. Just remove the unwanted fields from the views. If the table really is that big of a mess, and you never want to see those fields again, I would port the good parts of the records over into another, new table that is cleaner and slimmer. You could probably do that with an import set.


An easy way to find a column that is empty throughout the whole table though is probably like this:


var rec = new GlideRecord('u_my_table');
rec.addNotNullQuery('u_field_maybe_this_is_empty');
rec.query();

if(rec.hasNext()) {
       gs.print("At least one record on this table has data in this column.");
}