Query cmdb_rel_ci table and get parent records which contains terminated on field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2020 06:55 PM
Hi,
I am query cmdb_rel_ci table, with filter conditions as below:
child.class = aws_datacenter or azuredatacenter
I also want to add one more condition :
child.terminated_on is in last 24 hours.
Problem is, terminated on field is not there on cmdb_ci table, it is there only on few tables and I want only those record which have that field.
How do I write query?
I am trying some script as below :
var query = 'child.sys_class_name=cmdb_ci_aws_datacenter^ORchild.sys_class_name=cmdb_ci_azure_datacenter';
var gr = new GlideRecord('cmdb_rel_ci');
gr.addEncodedQuery(query);
gr.query();
while(gr.next())
{
var cs = new GlideRecord('cmdb_ci_vm_object');
cs.addQuery('sys_id',gr.parent.sys_id);
cs.query();
while(cs.next())
{
if(cs.terminated_on.isValid() == true)
{
gs.print(cs.name);
}
}
}
getting the below result:
ompacting large row block (file.write: cmdb_rel_ci 10000 rows 160000 saveSize)
Any suggestions?
- Labels:
-
Cost Management (ITSM)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2020 01:39 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2020 01:31 AM
Hi Rambo,
Kindly mark my response correct and helpful if my suggestion helped you,
Thanks
Murali