combine two codes in a reference qualifier

lmao
Tera Contributor

hello, i have an advanced reference qualifier with following code:

 

 

javascript: ['incident', 'problem'].indexOf(current.sys_class_name + '') == -1? '' : 'operational_statusNOT IN' + new OpsStatusFilter('cmdb_ci').by('CreateTask').join()

 

 

and i would like to add following conditions to it:

 

sys_class_name    IS ONE OF:

cmdb_ci_server

cmdb_ci_business_app

cmdb_ci_aix_server

cmdb_ci_datapower_server
cmdb_ci_esx_server
cmdb_ci_hyper_v_server
cmdb_ci_ibm_frame
cmdb_ci_ibm_zos_server
cmdb_ci_lb_bigip
cmdb_ci_linux_server
cmdb_ci_net_app_server
cmdb_ci_unix_server
cmdb_ci_vcenter_server_obj
cmdb_ci_win_server

 

can you advice me how?

12 REPLIES 12

lmao
Tera Contributor

hello and thank you a lot for your answer. i have updated the original post as i made a mistake. it should be "IS ONE OF" instead of "IS NOT ONE OF". im sorry for the confusion. how can i change the script in this way?

Uttkarsh S
Tera Contributor

Hi,

 

You can use below script:

 

var RestrictCIClass = Class.create();
RestrictCIClass.prototype = {
    initialize: function() {},

    restrictClasses: function(current) {
        var oldQuery = ['incident', 'problem'].indexOf(current.sys_class_name + '') == -1 ? '' : 'operational_statusNOT IN' + new OpsStatusFilter('cmdb_ci').by('CreateTask').join();
        var newQuery = oldQuery + '^sys_class_name=cmdb_ci_server^ORsys_class_name=cmdb_ci_business_app^ORsys_class_name=cmdb_ci_aix_server^ORsys_class_name=cmdb_ci_datapower_server^ORsys_class_name=cmdb_ci_esx_server^ORsys_class_name=cmdb_ci_hyper_v_server^ORsys_class_name=cmdb_ci_ibm_frame^ORsys_class_name=cmdb_ci_ibm_zos_server^ORsys_class_name=cmdb_ci_lb_bigip^ORsys_class_name=cmdb_ci_linux_server^ORsys_class_name=cmdb_ci_net_app_server^ORsys_class_name=cmdb_ci_unix_server^ORsys_class_name=cmdb_ci_vcenter_server_obj^ORsys_class_name=cmdb_ci_win_server^EQ';
		return newQuery();
    },
    type: 'RestrictCIClass'
};

 

Please mark the answer "Correct" or "Helpful", if it helps your case.

Cheers,

Uttkarsh

lmao
Tera Contributor

i have used this script and called the script include and also set the override to false. but still it wont filter out the other classes. there might be another issue why it wont work.

 

lmao_0-1711021487130.png

 

Uttkarsh S
Tera Contributor

@lmao , on which table you're trying to see the reference qualifier?

lmao
Tera Contributor

@Uttkarsh S on the change_request table.