does child table inherit new field created in parent table ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-01-2017 11:56 PM
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 ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-26-2017 04:33 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2018 05:35 AM
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();
}
----------------------------------------------------------------------------------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2022 03:34 AM
Hii
You can add configure form layout of Child table to add additional fields on form from parent table.