does child table inherit new field created in parent table ?

Vineetha Rohra1
Giga Guru

I have created a custom table that extends 'cmdb_ci' table.

After that i created a field in the cmdb_ci table. This field is not available for the custom table that i created in step 1.

How to make it available to all the tables which are extending cmdb_ci ?

i mean how to make that field available to all those tables to whom cmdb_ci is the parent ?

7 REPLIES 7

Hi Vineetha,



Anytime you add new field to parent, that field will automatically be inherited by all child tables. That is, there is nothing more that you need to do to make new custom field of parent to appear in all child tables. I verified in couple of places:



[#1 http://wiki.servicenow.com/index.php?title=Creating_a_Custom_Table#gsc.tab=0 ] has a line "For tables that extend another table, fields on the parent table also appear on the Table Columns embedded list for the current table. If you modify these fields, remember that all changes to fields on the parent table also affect all child tables, not just the current table."



[#2 add field on multiple forms ] also confirms that to add new field to all child, just add to parent, which will automatically show-up in all child tables.



Please mark correct, if this answers your question.


Thanks


Amar Lala


ServiceNow Admin Architect



Hello Everyone I have found the solution using Script     Please mark as helpful and hit like



--------------------------------------------------Adding field to formlayout of all child tables using script-------------------------------------------------------------






var tu = new TableUtils("u_test");             //base table name


var classes = tu.getHierarchy();  


gs.include("j2js");  


var jsClasses = j2js(classes);                       //get all child table as well as base table


var arr=[];  


var gr= new GlideRecord('sys_ui_section');  


gr.addQuery('name', 'IN', jsClasses);  


gr.addEncodedQuery('view=Default view^captionISEMPTY');  


gr.query();  


while(gr.next()){  


arr.push(gr.getValue('sys_id'));               //push the sys_id of the ui section with empty caption




}



for (i=0; i < arr.length; i++){  


var gr1= new GlideRecord('sys_ui_element');  


gr1.initialize();  


gr1.sys_ui_section=arr[i];  


gr1.position=-1;                                         //position of the field on form


gr1.element='u_final';                           //field   to be added on all form layout


gr1.insert();  



 


}  






----------------------------------------------------------------------------------------------------------------------------------------------------


Urmila Mane
Tera Contributor

Hii

You can add configure form layout of Child table to add additional fields on form from parent table.