- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2019 11:16 AM
Sorry for the wordy question...
I am querying a table with GlideRecord. The table has a reference column to the configuration item table. I only want to return records where the configured item in that column is a certain type. (a table that extends config. item)
I successfully achieve this with: record.addQuery("name_of_ref_col.sys_class_name", "name_of_extended_table");
However, I would like to also filter by a certain column in the extended table. Note: This column is not in the configuration item table, it is in a table that extends configuration item - the table I am filtering the results to with the above query.
This does not work: record.addQuery("name_of_ref_col.my_col", some_val);
Is this possible? Any suggestions?
The exact scenario is:
I am querying Indicator Scores (apm_app_indicator_score) where the configuration item is a Business Capability (cmdb_ci_business_capability). I want to add a query where Capability.hierarchy_level is 2.
This does not work: record.addQuery("cmdb_ci_business_app.hierarchy_level", 2)
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2019 02:16 PM
You need to reference the extended table in your query condition. For example, if you were querying on the Task table and you wanted to add a query for Incident State is New (1):
var task = new GlideRecord("task");
task.addQuery("ref_incident.incident_state", "1");
task.query();
So in your case, this should work:
record.addQuery("cmdb_ci_business_app.ref_cmdb_ci_business_capability.hierarchy_level", 2);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2019 02:16 PM
You need to reference the extended table in your query condition. For example, if you were querying on the Task table and you wanted to add a query for Incident State is New (1):
var task = new GlideRecord("task");
task.addQuery("ref_incident.incident_state", "1");
task.query();
So in your case, this should work:
record.addQuery("cmdb_ci_business_app.ref_cmdb_ci_business_capability.hierarchy_level", 2);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2019 06:40 AM
Perfect. Thanks Tony!