How to make an already created custom table extend another custom table?

UPASANA2
Mega Expert

How to make an already created custom table extend another custom table?

19 REPLIES 19

kumarg
Giga Contributor

Here is a script to extend an existing table.


Important Notes

  1. Always test first in a test or development ServiceNow instance
  2. This script does work with tables with data in them, however I suggest only running this on new or empty tables.
  3. This is a manual step and isn't captured in an update set.

Steps to extend table

  1. Elevate your privileges to security admin
  2. In scripts - background run this script (replacing variables as needed)
//Replace <source_table> with the table you want to extend 
//Replace <table_extension> with the table you want to extend to, like cmdb_ci or task
var table = '<source_table>';
var old_parent = '';
var new_parent = '<table_extension>';  
var changer = new GlideTableParentChange(table);
changer.change(old_parent, new_parent);

Hi,



I have been trying script it from many days. But I get this message when I run the script-> Hierarchy change for u_cpar ignored because new base table 'u_business_services' does not have (but needs) a sys_class_name field



we can extend inbuilt tables using this script, but not custom tables. Is there any other way which we can make this script work?


It worked for me in Istanbul instance. Both my tables are newly created and then made one of the table as parent to another table. Good script. Thank you


Vinobalu
Kilo Expert

Hi Upasana,



1. Deactivate the business rule "Table Field Validation".


2. In the list View extend the custom table.


3. Finally activate the business rule "Table Field Validation".