Query filter

nikhitha24
Tera Guru

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.

 

8 REPLIES 8

Stefan Georgiev
Tera Guru

Hello @nikhitha24 ,

you can use an Advanced Reference Qualifier to achieve this,

1) Create a script include with a function that needs the assignment group, script the logic based on assignment group what filter to use and return the filter in string format

2 Call the script include from your advanced RQ - javascript: new yourScriptInclude.yourFilter(assignement_group_id)

 

that way every time the assignment group changes the RQ is going to be different for the server.

 

Hope that this helps you!

If the provided information answers your question, please consider marking it as Helpful and Accepting the Solution so other community users can find it faster.

All the Best,
Stefan

@Stefan Georgiev 

 

Could please share the code as i have written the script include but it is showing no data to display when i select the variable.

Amit Verma
Kilo Patron
Kilo Patron

Hi @nikhitha24 

 

Just to be clear with the requirement, you want to auto-populate the Assignment Group based on value of Server Variable which refers server class table and the filter conditions you mentioned above . Is my understanding correct ?

 

Thanks & Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

Hi @Amit Verma 

Based on the selected server ci variable i need to write a script if a logged in user is part of that group in the selected server ci i can able to see those filter condition ci in this variable.

nikhitha24_0-1704440831301.png

 

script:

var Selectedservers = Class.create();
Selectedservers.prototype = {
    initialize: function() {
        var ritms = [];
        filterString = '';
        if (gs.getUser().getUserByID(user).isMemberOf("PSOAu - FPCS - Control Systems")){
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';
        }
        else if (gs.getUser().getUserByID(user).isMemberOf("")){

        }
    },

    type: 'Selectedservers'
};
 
please help me on this