How to add Reference Qualifier on Additional Assignee List for users that are members of a group?

JC S_
Mega Guru

We are trying to add a reference qualifier for the field Additional Assignee List to limit the users shown on the lookup for users that are members of a certain group. We can see that there is a filter value for the role the user has but there is none for the groups he is part of.

UPDATE:

Thanks to everyone who provided feedback, especially to explorenow and harshvardhansingh.

1 ACCEPTED SOLUTION

Hi explorenow thanks for this, we used this and modified a bit to fit on our exact requirement.



For other users with this similar requirement, just refer to the steps below:



Here's the final script we used to achieve our requirements:


var FindGroupMember = Class.create();


FindGroupMember.prototype = {


      initialize: function() {


var grp = current.assignment_group;


var x; //Variable that will hold the group of members you want to show



//If Assignment Group is Group A then show members of Group B


if(grp=='<insert sys_id of Group A>'){


x = '<insert sys_id of Group B>';


}



//Code to return members of the group


var answer = [];


var gr = new GlideRecord('sys_user_grmember');


gr.addQuery('group', x);


gr.query();


while(gr.next()){


answer.push(gr.user.toString());


}


return 'sys_idIN' + answer;


},


      type: 'FindGroupMember'


};



HOW TO SETUP:


  1. Create a new script under System Definition > Script Includes
  2. Use the final code above
  3. Configure the Dictionary of Additional Assignee List field
  4. DO NOT change the setup on Reference Specification
  5. Go to Dictionary Overrides on the bottom of the page and click New
  6. Change table to Incident (this allows you to just change the lookup of Additional Assignee List field while you are on Incident table, on other tables, it will just work as OOB)
  7. Check 'Override reference qualifier'
  8. Paste the code below on the R


javascript:new FindGroupMember().initialize();



RESULTS:


When Assignment Group is Group A, then lookup for Additional Assignee List will return users of Group B.


View solution in original post

16 REPLIES 16

antin_s
ServiceNow Employee
ServiceNow Employee

Hi Jimboy,



This can be done by modifying the dictionary of additional_assignee_list field. By clicking on the 'Advanced View' in the Related Links, you may create an advanced Reference Qualifier which has script to get the list of sys_ids based on your need (of a specific group, location..etc)



find_real_file.png



javascript:new UserUtil().getUserIds() is an example. You might have to create your own script and use it here.



Hope this helps. Mark the answer as correct/helpful based on impact.



Thanks


Antin


Shishir Srivast
Mega Sage

Please try below script and see if it helps.



var FindGrpMember = Class.create();


FindGrpMember.prototype = Object.extendsObject(AbstractAjaxProcessor, {


getGroupMember : function()


{


  var grp = current.<field name of group>;   //Pass the variable name which selects Group


  var answer;


  var gr = new GlideRecord('sys_user_grmember');


  gr.addQuery('group', grp);


  gr.query();


    while(gr.next()){


    if (answer.length > 0) {


    answer =+ (',' + gr.user.getValue("sys_id"));


  }


  else{


  answer= gr.user.toString();


  }


}


    return 'sys_idIN' + answer;


},


type: 'FindGrpMember'


});



Then in reference qualifier please call the like: javascript:new FindGrpMember().getGroupMember();


Hello, where do we create this script?


Please create as a script include.