How to change parent of a table?

Suresh Vemanna1
Kilo Contributor

Hello Experts,

I am trying to change the parent table of one table.

I have gone through few posts on community and found the below methods which can change the parent of a table. But it is always returning 'false' for me.

//var changer = new Packages.com.glide.db.table.TableParentChange('u_load_balancer');
//var g = changer.change('cmdb_ci_netgear','cmdb_ci_server');  
//gs.print(g);
 
var changer = new GlideTableParentChange('cmdb_ci_lb');
var g = changer.change('cmdb_ci_server','cmdb_ci_netgear');
gs.print(g);
 
I have found reParentTable() method from CMBDUtil API in the ServiceNow docs. But even this returned "false".
var gr = SNC.CMDBUtil.reParentTable('cmdb_ci_lb', 'cmdb_ci_server', 'cmdb_ci_netgear');
gs.print(gr);

I tried the same even for my custom tables, which I made sure that the tables are extensible. But still it didn't work.

I have elevated roles to 'security_admin' and tried, even this didn't work.

 

Has anyone tried changing the parent of a table?

Please note I do not want to create a new table to extend from the parent table I desire.

Please let me know the correct way to change the parent of a table.

 

Many thanks in advance.

Br,

Suresh

10 REPLIES 10

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Suresh,

can you try to do this and it should work; use the new keyword

var gr = new SNC.CMDBUtil.reParentTable('cmdb_ci_lb', 'cmdb_ci_server', 'cmdb_ci_netgear');
gs.print(gr);

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Ankur,

Thanks for your response.

reParentTable() is a static method of CMDBUtil API, so it has to be called as 'SNC.CMDBUtil.reParentTable('cmdb_ci_lb', 'cmdb_ci_server', 'cmdb_ci_netgear');'.

 

 

Harsh Vardhan
Giga Patron

there is a workaround for this.

 

if you want you can try on custom table and validate if this is working fine or not. 

 

There is OOTB business ("Table Field Validation") rule which prevent the edit on "Extends table" field after creation of table. 

you can disable this business rule for few minutes and then run the below code in background script . 

 

var gr = new GlideRecord('sys_db_object');
gr.get('f8526f9adb753340e4d95740cf96192a'); //which table you want to make changes

gr.super_class='c22fbc47db222300e4d95740cf961938'; // set the table which you want to set
gr.update();

 

Note: This is just a workaround.  Once you run the above code then mark the active true on "Table Field Validation" business rule. 

 

 

xinyao
ServiceNow Employee
ServiceNow Employee

We are encountering the same problem here. All suggestions mentioned above are not working. Maybe those solutions are already out of date. Hope someone can help and update the solution. Thanks!