- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2023 05:52 AM
Hello Team,
i need to know that how addJoinQuery work and pass the sys_id.
var thisCI='dfgh1111'// this is CI
var grParentCIName = new GlideRecord('cmdb_ci_business_app');
grParentCIName .addEncodedQuery('u_active=true^sys_class_name=cmdb_ci_business_app');
var jq1 = grParentCIName .addJoinQuery('cmdb_rel_ci','sys_id','parent');
jq1.addCondition('child', thisCI);
grParentCI.query();
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2023 11:28 AM
It looks like there are a couple of issues with the provided code. Here's a version of the code with some corrections:
var grParentCI = new GlideRecord('cmdb_ci_business_app');
grParentCI.addQuery('u_active', true);
grParentCI.addQuery('sys_class_name', 'cmdb_ci_business_app');
var jq1 = grParentCI.addJoinQuery('cmdb_rel_ci', 'sys_id', 'parent');
jq1.addCondition('child', thisCI);
grParentCI.query();
Here are the changes I made:
I removed the extra space between grParentCIName and the . in the first line.
I changed grParentCIName to grParentCI to be consistent with the rest of the code.
I replaced the addEncodedQuery method with addQuery and passed the values as separate arguments. This is a more standard way to add queries to a GlideRecord.
I fixed the typo in the last line where grParentCI was mistakenly referred to as grParentCIName.
These changes should help ensure that the query runs as intended. Note that I assume thisCI is a variable that contains the sys_id of a CI, as it is used in the join condition. If that is not the case, you may need to adjust the code accordingly.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2023 11:28 AM
It looks like there are a couple of issues with the provided code. Here's a version of the code with some corrections:
var grParentCI = new GlideRecord('cmdb_ci_business_app');
grParentCI.addQuery('u_active', true);
grParentCI.addQuery('sys_class_name', 'cmdb_ci_business_app');
var jq1 = grParentCI.addJoinQuery('cmdb_rel_ci', 'sys_id', 'parent');
jq1.addCondition('child', thisCI);
grParentCI.query();
Here are the changes I made:
I removed the extra space between grParentCIName and the . in the first line.
I changed grParentCIName to grParentCI to be consistent with the rest of the code.
I replaced the addEncodedQuery method with addQuery and passed the values as separate arguments. This is a more standard way to add queries to a GlideRecord.
I fixed the typo in the last line where grParentCI was mistakenly referred to as grParentCIName.
These changes should help ensure that the query runs as intended. Note that I assume thisCI is a variable that contains the sys_id of a CI, as it is used in the join condition. If that is not the case, you may need to adjust the code accordingly.