I have to write a script include to exclude the Assignment group from choosing the user .

swetha kurukund
Kilo Explorer

Hi All, 

 

I have to write a script include to exclude the Assignment group from choosing the user . 

I am going to call this script include function in the reference qualifier . 

Assignment group is a reference type field

 

Below is the script include i have created but it is not working accordingly . I am not sure how to exclude that one group and return all the other group as it is in that assignment group field .

 

var Hide _groups = Class.create();

Hide_ groups.prototype = {

              filters1: function() {

             

                             //Quering on group

                            

                             var gr = new GlideRecord('sys_user_group');

                            gr.addQuery('name',XYZ);       // XYZ is the name of the assignment group .This is the only group i am trying to exclude showing from the list                       

                             gr.query();

                             var qry =[];

                             while(gr.next()){

                                                          qry.push(gr.sys_id.toString());

                                                         

                                           }

                                                          else qry.push(gr.sys_id.toString());

                             }

             

                             },

             

              type: 'Hide _groups'

};

17 REPLIES 17

Calvaresi E_
Giga Expert

Hi Arizona,
in the Advanced qualifiers value of the field, you should use this syntax:
javascript:new yourScriptInclude().your_refqualFunction()

The function you are coding must return a query string that can filter the options available on a reference field, like this:

 

function your_refqualFunction(){

  var filter=[];

  var gr= new GlideRecord('sys_user_grmember');

  gr.addQuery("group.manager","Will Smith");

  gr.query();

  while(gr.next()){

  filter.push(gr.getValue("user"));

  }
  return "sys_idIN"+filter.join();
}

Let me know if it helps

Hi, 

 

I tried this way and it is not even going to the next step after while(gr.next) and in the Advanced qualifiers value of the field, you should use this syntax:
javascript:new yourScriptInclude().your_refqualFunction(). I have used the same syntax. 

In your code, you have ELSE without IF, I don't know if that's gonna work. If you have your code revised, can you please post the updated script?

Ok .I have removed that code and trying what edoardo.c suggested and that is also not working .