Placing a cmdb_ci table field to all related forms

niitnishant
Tera Contributor

Hi Friends,  

Can somebody please share your experience on below-   I have a new field in cmdb_ci table. Now i need to place this new field on all the FORMS of different classes in relation to cmdb_ci e.g. Business Applications, Servers, Network etc.  

Thanks in advice!

Nishant

9 REPLIES 9

borjam_
Kilo Contributor

Hi Nishant,



Any table which extends another automatically inherits all fields from the base table, so you can use them right away. However, there is no way, as far as I know, to automatically display the field in the child form, as each form may have different fields and you would probably have to modify the form layout anyway. As Manoj Kumar showed in his answer, you can follow those steps in order to display the field in the child forms.



I'd like to add something else that Manoj did not mention. You can have a dictionary override for the field for each of the child tables, so they have a different label, reference qualifier, and some other options, while maintainig the same field name, type, and other properties. This way you can reference the same field from the different tables if you need it but with some of the properties having specific values different from the rest. You can create these Dictionary Overrides you need to create a it in the base-table field dictionary (there should be a related list below). Note that if you want to override the field for an specific child table you don't need to create a Dictionary Override for all the child tables, just for those you do want them to have specific properties (the tables which do not have an specific override will inherit the field just as it is in the base table). You have more information in the ServiceNow Wiki.



Regards,


Borja Magdaleno


niitnishant
Tera Contributor

Hi All,



Thanks for your response. All i am looking for is a shortcut to place the new fields on all the desired forms. Placing the field with 'Configure Layout' option on each form is very time taking, as there are so many classes, hence so many forms.



Please advice.



Thanks,


Nishant


I have this exact same question if anyone knows a shortcut to getting a field to appear on all child forms.



I was asked to create a new field named 'Criticality' for use on cmdb records... since the user did not want to limit this data being applicable to just the Business Service level. I created the field on the cmdb_ci table, but it appears that I have to go in and configure every form for the child tables too (cmdb_ci_server, cmdb_ci_win_server, cmdb_ci_network_gear, cmdb_ci_ip_router, etc.............).



The only way I can think to maybe make this work is to create a new form section on the parent table and include the field. I hesitate in doing this though since I'm only adding a single field and I really don't want a single-field section


Try the below untested code.



var tu = new TableUtils("cmdb_ci");


var classes = tu.getHierarchy();


gs.include("j2js");


var jsClasses = j2js(classes);


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.sys_id.toString());


}


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


var gr1= new GlideRecord('sys_ui_element');


gr1.initialize();


gr1.sys_ui_section.sys_id=arr[i];


gr1.poistion=-1;


gr1.element='u_new_field';


gr1.insert();




}


Hello

Take a look to this answer from @Marc Stanger

https://community.servicenow.com/community?id=community_question&sys_id=ce4ccb65db9cdbc01dcaf3231f961999

 

Please, mark correct or useful if i helped you

Thanks

Ariel