- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2017 04:31 AM
Hi All,
Can someone please help with the below Business rule .When checking the logs it shows as rows retrieved: 0 . Please guide.
(function executeRule(current, previous /*null when async*/) {
var sci = current.u_sourceci;
var rel = new GlideRecord('u_maximo_cmdb_ci');
rel.addQuery('u_cinum', sci);
rel.addQuery('u_hierarchypath', 'OPERATING SYSTEM \ AIX');
rel.addQuery('u_cmdb_class_name', 'u_cmdb_ci_logical_partition');
rel.query();
gs.log("rows retrieved :"+rel.getRowCount());
if(rel.next()){
gs.log("HELLO IF");
current.u_aixlpar = 'True';
}
})(current, previous);
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2017 05:53 AM
Found it! It's definitely the backslash. It's a special character in Javascript that says 'the next character goes with this like \n, \t, etc.' To get it to work, change your query to use double backslash. That tells Javascript that the next character is a backslash, not a special character;
u_hierarchypath=OPERATING SYSTEM \\ AIX^u_cmdb_class_name=u_cmdb_ci_logical_partition
Sorry, I should have seen this earlier. It's been a crazy week.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2017 05:10 AM
Hi Chuck,
I tried with below as you suggested, still it returned 0 records.
(function executeRule(current, previous /*null when async*/) {
var rel = new GlideRecord('u_maximo_cmdb_ci');
rel.addEncodedQuery('u_hierarchypath=OPERATING SYSTEM \ AIX^u_cmdb_class_name=u_cmdb_ci_logical_partition');
rel.query();
gs.log("rows retrieved :"+rel.getRowCount());
gs.log("Result :"+rel.getEncodedQuery());
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2017 05:13 AM
Thanks for your patience.
I would try it two more times. One with just the first part of the query and one with the second. Something still tells me that backslash is trouble.
Test #1 use this:
rel.addEncodedQuery('u_hierarchypath=OPERATING SYSTEM \ AIX');
Test #2 use this:
rel.addEncodedQuery('u_cmdb_class_name=u_cmdb_ci_logical_partition');
Let me know how many records you get counted from each of those.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2017 05:35 AM
Hi Chuck,
Thanks for your patience.
I tested in both cases. below is the results.
Test #1 use this: rows retrieved :0
rel.addEncodedQuery('u_hierarchypath=OPERATING SYSTEM \ AIX');
Test #2 use this:rows retrieved :50
rel.addEncodedQuery('u_cmdb_class_name=u_cmdb_ci_logical_partition');
Please guide.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2017 05:43 AM
Thank you. This proves my theory that backslash is being a problem.
Let me do a little testing to see what I can come up with for a fix out of this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2017 05:45 AM
Ok Thanks Chuck. I will be waiting for your response. Please Guide as I am not able to find a solution for this.