I have created one field (Business Area) in CMDB_CI table and added in to form through Form layout. So here my question is, how it should populate all child classes in CMDB. I shouldn't go to every Class and i should not use form layout for every cla

rmaheshg80
Kilo Contributor

I have created one field (Business Area) in CMDB_CI table and added in to form through Form layout. So here my question is, how it should populate all child classes in CMDB. I shouldn't go to every Class and i should not use form layout for every class. Because we have min 100 to 500 + child classes. So it will take huge time. So how can i get it ?

5 REPLIES 5

Fabian Kunzke
Kilo Sage
Kilo Sage

Hello,

Firstly i would like to seperate your question into 2 major points:

1) You added a field to the cmdb_ci table and you would like to populate all child classes.

This will (and should) happen automatically. The new field you added should be available in all child classes.

2) Fields added to a parent class should show in the form of any child class.

As far as i know, any field added to any table will automatically be present at the bottom of the "default" layout of said table. Theoretically this should also account for fields added via inheritance (parent->child). Therefore after adding said field to the cmdb_ci table all child tables should have that field on the "default" form. Why theoretically? I have never tried adding a field to the cmdb_ci table. Therefore i am bound to the theory of what i have already tried.

Other than that: Any other view will not be changed. Meaning that most of the work still has to be done manually. (Again, never tried this specific use case)

 

tl:dr: Except from the default views (which are rarely used within the cmdb enviroment) you will have to rework the views for each table. From what i know the default view of the child tables will be extended by the new custom field (it will be added on the bottom).

 

Greetings

Fabian

pranali09
Kilo Expert

Hello,

We dont have such configuration through which it will get add in all child classes in one go however you can achieve this through background script.

Note: Please test and try below code in your dev instance for other tables first and try for cmdb_ci table.

First you need to create a parent table and 2-3 child tables which extends parent.

We need to get below 3 values so that you can provide it in below code:

field name, position, sys_id of field.

 

You can get those values by capturing your parent formlayout change in your update set. You will get the values in xml like below.

 

We need write a background script like below:

var child = new GlideRecord('sys_db_object');
// provide sys id of the parent table
child.addQuery('super_class', 'b2e736174f32130084f7b4a18110c7e7');
child.query();
while(child.next())
	{
	var childSection = new GlideRecord('sys_ui_section');
	childSection.addQuery('name',child.name);
	childSection.query();
	while(childSection.next())
		{
		var element = new GlideRecord('sys_ui_element');
		element.sys_ui_section = childSection.sys_id;
		element.element = 'u_test1_feild'; //field name to be added in layout
		element.position = '3'; //whatever position you have in parent
		element.sys_id= '4ce6657f4ffa130084f7b4a18110c75e'; //field sys id to be added in layout
		var sysid = element.insert();
		gs.print('sys id id: ' + sysid);
	}
}

 

Please note that changes will happen for immediate child classes and not for child of child.

We can achieve that as well to do changes in child of child.

Kindly try this first then we will check further if you have that requirement.

 

Regards,

Pranali Kadam

|www.DxSherpa.com|

Hello,

 

I hope the solution provided is helpful to achieve your requirement.

 

If it is then can you mark it as correct answer.

 

Let me know if you have any further concern regarding this solution.

 

Regards,

Pranali Kadam

|www.DxSherpa.com|

 

 

 

pranali09
Kilo Expert

Hello,

 

I hope the solution provided is helpful to achieve your requirement.

 

If it is then can you mark it as correct answer.

 

Let me know if you have any further concern regarding this solution.

 

Regards,

Pranali Kadam

|www.DxSherpa.com|