- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2024 04:32 PM
Hi All,
i trust this email finds you well.
i do have a script include with a function that runs an encoded query.
it does not work as is, but if i replace "baname" (line 3) with the name of the business application in the query, rather than using the variable it works.
why?
var baname= 'cape';
var gr = new GlideRecord('cmdb_rel_ci'); //ref_cmdb_ci_hardware
gr.addEncodedQuery('parent.name=cape^child.operational_status=12^child.ref_cmdb_ci_hardware.u_ci_eol_status=expired');
gr.query();
while(gr.next()) {
gs.print('found another' + gr.child.name);
}
"
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2024 04:47 PM
In the code you've shared you're not using baname on line 3. Please share the code that isn't working.
You'll need to ensure you concatenate your variable:
gr.addEncodedQuery('parent.name=' + baname + '^child.operational_status=12^child.ref_cmdb_ci_hardware.u_ci_eol_status=expired');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2024 04:47 PM
In the code you've shared you're not using baname on line 3. Please share the code that isn't working.
You'll need to ensure you concatenate your variable:
gr.addEncodedQuery('parent.name=' + baname + '^child.operational_status=12^child.ref_cmdb_ci_hardware.u_ci_eol_status=expired');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2024 04:50 PM
Hi @El Cuchi
you're defining the bname variable but you are not actually using it in the addEncodedQuery() method.
If you want to use it you need to insert dynamically into the query like below:
gr.addEncodedQuery('parent.name='+ baname +'^child.operational_status=12^child.ref_cmdb_ci_hardware.u_ci_eol_status=expired');
Thanks and regards
Sai venkatesh