Is it possible to filter out cmdb_ci based on sys_class_name.

Swati44
Kilo Expert

Hello All,

I need to filter out cmdb_ci list using query business rule.

var test=current.sys_class_name;

var test1=current.getValue('sys_class_name');

  gs.log("&&&test"+test);

  gs.log("@@@@test1"+test1);

  if(current.sys_class_name=='cmdb_ci_server')

  {     gs.log("&&&&&&before");

  var encodedQuery='sys_class_name=cmdb_ci_server^operational_status=1';

  current.addEncodedQuery(encodedQuery);

  gs.log("&&&&&&after");

  }

Am not able to enter to the if loop, because test and test1 are null and empty.

How can i solve this? Please advice.

9 REPLIES 9

Hi Jeevan,



There are more than fifty classes, i want all records from those classes except few classes.


ie., Result should contain filtered record of few classes and all records of other classes.


HI Swathi,



If you need to filter out a small number of classes try changing your encoded query to 'is not'



operational_status=1^sys_class_name!=cmdb_ci_unwantedclass1^ORsys_class_name!=unwantedclass2^ORsys_class_name!=cmdb_ci_unwantedclass3


Swati,



It is possible , you just need to change the encoded query . Easy way to build the encoded query is to open the cmdb_ci table in list view and use the condition builder to search for your choice of CI's ..then right click and copy the encoded query and add to business rule. Refer the below screenshot ,adjust the query as per your requirement and copy & past to the business rule.



find_real_file.png



Thanks,


Jeevan


Hi jeevan,



Thank you, I did as you said, but no result.


Can you paste a screenshot of what you did ?