We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

how to get child table field into parent table

yekambaram
Kilo Contributor

Hi thanks in adv,

How to get child table field into parent table.

Eg: parent table is cmdb_ci table and child table is cmdb_ci_server.

the field classification is present in cmdb_ci_server table but i want to get that filed into parent table cmdb_ci table

  var child = new GlideRecord('cmdb_ci');

                     

  child.addQuery('operational_status',1); //operational status field is present in cmdb_ci table so it gets filtred and working fine

but when i try to filter child table field its not getting

child.addQuery('classification','production'); // its not working because the classification field is present in the cmdb_ci_server.

how to filter the records based on classifiacation from cmdb_ci glide record

20 REPLIES 20

Chuck Tomasi
Tera Patron

Hi Suresh,



Are you looking to MOVE the field from cmdb_ci_server to cmdb_ci or just copy a value?



If you want to move (or promote) the field, work with customer support on this. If you simply want to copy the value of a field, please provide more detail where you are trying to copy the field to.


Hi chuck,



I want to retrieve/get the records based on the field which is present in the   child table, from parent table through glide record.



find_real_file.png


when we click on the ref icon then it should return the records of server where classification is 'Production' (classification is present on server table which is a child table to cmdb_ci table)


Hi suresh,



Here you can do two things


1) create a new field on cmdb_ci table and copy the date over to cmdb_ci table


2) You can write a glide reecord query on cmdb_ci_server table and return all the sys_id's. But not sure how the performance of it would be.


Hi Abhinay,


thanks for the reply,


i tried the below code but this is not right one but the requirement is like that


  var child = new GlideRecord('cmdb_ci');


child.addQuery('classification','production');


//classification field is present in cmdb_ci_server table (eg:child.addQuery('cmdb_ci_server.classification','production');


child.query();



i want to query child table field from parent table through glide record