combine two codes in a reference qualifier
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2024 03:03 AM - edited 03-21-2024 04:26 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2024 04:28 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2024 04:35 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2024 04:45 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2024 05:06 AM
@lmao , on which table you're trying to see the reference qualifier?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2024 05:28 AM
@Uttkarsh S on the change_request table.