What's the opposite of INSTANCEOF?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2015 02:55 PM
I have a given class name, such as 'cmdb_ci_linux_server'. Now I want to find all the cmdb_model entries that would be a valid choice for an asset of type cmdb_ci_linux_server, so I started off like so:
var gr = new GlideRecord('cmdb_model');
gr.addQuery('status', '!=', 'Retired');
gr.addNotNullQuery('name');
gr.addQuery('cmdb_ci_class', 'INSTANCEOF', 'cmdb_ci_linux_server');
gr.query();
But that INSTANCEOF is backwards. Is there a way to flip that around? So basically I want to return all models where the cmdb_ci_class belongs to a table that cmdb_ci_linux_server inherits from. I want a PARENTOF type qualifier
Is there an easy way to do that, or do I just have to use TableUtils() and manually build up a big or statement?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2015 07:10 PM
Unless there is a undocumented operator that someone is privy to, you'll have to use TableUtils()
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2022 04:39 PM
I would do it this way
var gr = new GlideRecord('cmdb_model');
gr.addQuery('status', '!=', 'Retired');
gr.addNotNullQuery('name');
gr.addQuery('cmdb_ci_class', 'IN', j2js(GlideDBObjectManager.get().getTables('cmdb_ci_linux_server')));
gr.query();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2025 02:12 AM
you can use the class path