how to get child table field into parent table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2016 06:41 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2016 07:20 AM
You will have to query on cmdb_ci_server table, since the classification is on server table and return the sys_id's. It will be something like this. But not sure if this is performance effective.
var ids=[];
var gr= new GlideRecord("cmdb_ci_server");
gr.addQuery('classification','production');
gr.query();
while(gr.next()){
ids.push(gr.getValue("sys_id"));
}
return "sys_idIN"+ids.toString();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2016 07:21 AM
Minor tweak to the last line... for proper JavaScript operation on an array.
return "sys_idIN"+ids.join(',');

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2016 07:25 AM
Oh yeah, I always forget about the join() method. Thanks chuck
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2016 07:34 AM
Yes abhinay by the above code we can filter .But my requirement is something different from the parent table glide record i want to filter the field of child table
simply i need based on child table field i want to filter the records of cmdb_ci parent table

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2016 07:39 AM
That is what my code is doing. I am querying the child table "cmdb_ci_server" and returning the records on the parent table cmdb_ci