How to check the dependencies of a field on a table .

chaitanyakumarD
Tera Contributor

In cmdb_ci_handheld_computing i  have 3 fields 

Business Unit Owned : u_cmdb_business_unit(reference field )
Business Unit : business_unit (reference field )

Business Unit Used: u_ci_visibility(list collector)

now all are referring  to same business unit  table only  and I don't know where these fields are used or any dependencies  over these fields 

 now  with out Business Unit Used field the particular business unit  users are not able to access their records

I want to know the dependencies of other two fields whether required or used in any other parts of ServiceNow .how can I achieve it .

2 REPLIES 2

Mark Manders
Mega Patron

You can do a code search for the fields, but that will just show you where they are used in scripting. 

You will need to go through all tables to see if they are referenced anywhere as field or not. 


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Shruti Khaire
Kilo Sage

Hello @chaitanyakumarD,

 

You can try running the background script by modifying table and fields as per your requirement.

Background script:

var tableName = 'your_table_name';
var fieldName = 'your_field_name';

// Find all references to the field in scripts, business rules, UI policies, etc.
var gr = new GlideRecord('sys_metadata');
gr.addQuery('script', 'CONTAINS', fieldName);
gr.addQuery('script', 'CONTAINS', tableName);
gr.query();
while (gr.next()) {
gs.print('Referenced by: ' + gr.getValue('name') + ' (' + gr.getRecordClassName() + ')');
}

// Find all related list layouts, forms, etc.
var grList = new GlideRecord('sys_ui_element');
grList.addQuery('name', tableName + '.' + fieldName);
grList.query();
while (grList.next()) {
gs.print('Referenced in list/form: ' + grList.getValue('name') + ' (' + grList.getValue('type') + ')');
}

 

Hope that helps!