I want to know where custom fields are being used

Suzanne H
Giga Guru

Does anyone know of a way to see if custom fields are being used and if so, where?

1 ACCEPTED SOLUTION

@Suzanne H 

Hope you are doing good.

Did my reply answer your question?

If so, please mark appropriate response as correct & helpful so that the question will appear as resolved for others who may have a similar question in the future.

Thanks!
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

7 REPLIES 7

Suzanne H
Giga Guru

Ankur,

It's not the solution I was hoping for but I suppose it works.  I was hoping I could get a list of unused fields so that I could easily deactivate several at a time.

I appreciate your response. Thank you

A_CHAOUAY
Tera Contributor

Hello All,

I found this script in the community. It might help to get the unused fields in the incident table.
All that you need is to replace the table name.

var table = 'incident';
var gr = new GlideRecord(table);
gr.setLimit(1);
gr.query();
gr.next();
var fields = gr.getFields();
for (var i = 0; i < fields.size(); i++) {
        var field = fields.get(i).getName();
        var empty = isEmpty(table, field);
        gs.print('Column: ' + field + ' Empty: ' + empty);
}
function isEmpty(table, column) {
        var col = new GlideRecord(table);
        col.addNotNullQuery(column);
        col.setLimit(1);
        col.query();
        return !col.hasNext();
}

Good luck.

 

where to write this script? and how to find those unused field? i am new to it