The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Setting true/false flag for field using business rule

Mrman
Tera Guru

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);

1 ACCEPTED SOLUTION

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.


View solution in original post

23 REPLIES 23

vinothkumar
Tera Guru

Hello Ravi,



If Source CI is a reference field, you have to pass the sys id value in the query.


Hi Murugan,



Source CI is not Reference Field .



I logged as gs.log("Result :"+rel.getEncodedQuery());



Below is what I found in logs



Result :u_cinum=TESTAIXLPAR123C^u_hierarchypath=OPERATING SYSTEM AIX^u_cmdb_class_name=u_cmdb_ci_logical_partition



It is not taking as OPERATING SYSTEM \ AIX . Please let me know what can I add to match this


Mrman
Tera Guru

Hi All,



I logged as gs.log("Result :"+rel.getEncodedQuery());



Below is what I found in logs



Result :u_cinum=TESTAIXLPAR123C^u_hierarchypath=OPERATING SYSTEM AIX^u_cmdb_class_name=u_cmdb_ci_logical_partition



It is not taking as OPERATING SYSTEM \ AIX




I suspect the backslash is messing you up. Have you tried this?



rel.addEncodedQuery('u_cinum=TESTAIXLPAR123C^u_hierarchypath=OPERATING SYSTEM%20%92%20AIX^u_cmdb_class_name=u_cmdb_ci_logical_partition');