Query filter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2024 05:18 AM
Hi Team,
Can someone please help me on the below query.
- Assignment group = PSOAu - FPCS - Control Systems Select
- Filter: sys_class_name=cmdb_ci_win_server^ORsys_class_name=cmdb_ci_linux_server^install_status=1^manufacturerLIKEVMware^dns_domainINjbar.irnnew.bhpbilliton.net.au,mac.irnnew.bhpbilliton.net.au,mookaocrs.com,nhub.irnnew.bhpbilliton.net.au,npd.irnnew.bhpbilliton.net.au,ob24.irnnew.bhpbilliton.net.au,port.local,waio-opsnet.local,yandi.irnnew.bhpbilliton.net.au';
- Assignment group CONTAINS Hosting AND Assignment group CONTAINS Hypervisor
- Filter: sys_class_name=cmdb_ci_win_server^ORsys_class_name=cmdb_ci_linux_server^install_status=1^manufacturerLIKEVMware
- Assignment group = Hosting - Tools & Auto - Automation - MinAu
- Filter: sys_class_name=cmdb_ci_win_server^ORsys_class_name=cmdb_ci_linux_server^install_status=1^manufacturerLIKEVMware
Want to write a script for the conditions need to visible on the selected server variable it is reference table for the server class.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2024 11:54 PM
Hi @nikhitha24
So you want to populate only those CIs in the Select Server CIs variable where the logged in user is part of the Assignment Group for that particular CI ?
Thanks & Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2024 12:40 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2024 01:33 AM
Hi @nikhitha24
Please refer to the following background script and update your script include accordingly :
// Get All User Groups
var arr_util = new global.ArrayUtil();
var userGroups = arr_util.convertArray(gs.getUser().getMyGroups());
// Array to Collect User Managed by Group CIs Sys_id
var CIs = [];
// Make an instance of cmdb_ci_server Table
var gr = new GlideRecord('cmdb_ci_server');
// Iterate over the user Groups and fetch the CIs where current logged in user is part of the managed by group
for(var i=0 ; i < userGroups.length ; i++){
gr.addQuery('managed_by_group',userGroups[i]);
gr.query();
if(gr.next()){
CIs.push(gr.sys_id.toString());
}
}
gs.print(CIs);
Thanks & Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2024 01:40 AM
Hi @nikhitha24
Found a really simple solution while exploring. You can make use of a Simple Reference Qualifier as shown in the snip below to achieve this :
I have checked it on my instance and it is working as expected. Please test and let me know the results.
Thanks & Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.