- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2024 11:51 AM
Trying to restrict 120 records not being available for selection for a field 'VM Name'(referencing to vmware_instance) and it has reference qualifier as shown below:
I have added the condition to restrict for 4 records using (isnot or isnot or isnot) line 6 but it is still not working, Script Include is below:
getvm_tech1: function(tech) {
var data = '';
gs.log('ci tech ' + tech);
var ci = new GlideRecord('cmdb_ci_vmware_instance');
//ci.addEncodedQuery('state=on^install_status=1');
ci.addEncodedQuery('state=on^install_status=1^NQname!=VAARAWASH01^ORname!=VAARCDASH01^ORname!=VAARCPASH01^ORname!=VAARCPASH02');
if (tech == 'Database - Oracle' || tech == 'Linux') {
gs.log('ci tech 1' + tech);
ci.addEncodedQuery('guest_os_fullnameSTARTSWITHRed Hat Enterprise Linux');
} else if (tech == 'Database - SQL' || tech == 'Windows') {
gs.log('ci tech 2' + tech);
ci.addEncodedQuery('guest_os_fullnameSTARTSWITHMicrosoft Windows Server');
} else {
gs.log('ci tech 3' + tech);
return 'sys_idISEMPTY';
}
ci.query();
gs.log('ci count ' + ci.getRowCount());
while (ci.next()) {
gs.log('ci next ');
data += ci.sys_id + ',';
}
return 'sys_idIN' + data;
},
Any idea what needs to be done here?
Thank you!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2024 01:05 PM
Hi Shidhi,
The one ting that I can see is that in your initial addEncodedQuery you have a lot of ORs around name. If you have a device named VAARCPASH01, it will likely get included since that device passes the first test. Have you tried changein gthose Ors to ANDs?
:{)
Helpful and Correct tags are appreciated and help others to find information faster
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2024 01:05 PM
Hi Shidhi,
The one ting that I can see is that in your initial addEncodedQuery you have a lot of ORs around name. If you have a device named VAARCPASH01, it will likely get included since that device passes the first test. Have you tried changein gthose Ors to ANDs?
:{)
Helpful and Correct tags are appreciated and help others to find information faster
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2024 01:12 PM
Hi @Shidhi,
I would recommend simplifying the query and testing one by one.
I can't comment if your query is correct or not, but I would recommend changing the following lines of script:
//var data = '';
var data = []; //change to array
//data += ci.sys_id + ',';
data.push(ci.getUniqueValue());
//return 'sys_idIN' + data;
return 'sys_idIN' + data.join(',');
Cheers