I want to remove the the user from assigned to field but the user must present in the group??

gokulraj
Giga Expert

My requirement is to hide the user1 from assigned to when selecting the assignment group while creating an incident ,but the user must be a member in   the group.

1 ACCEPTED SOLUTION

This needs to be added as an advnaced reference qualifier to the assigned_to field, not assignment_group.


View solution in original post

26 REPLIES 26

The below script include should work, amend the user sys_id in the encoded query, call the script include excludeUser and call it as an advanced reference qualifier with the syntax: javascript: new excludeUser().excludeUser()



var excludeUser = Class.create();


excludeUser.prototype = {


initialize: function() {


},



excludeUser:function() {


var users = "sys_id=1234";



if(current.assignment_group.getDisplayValue() == 'Network'){



var gr = new GlideRecord('sys_user_grmember');


gr.addEncodedQuery('group=' + current.assignment_group + '^user!=insert your users sys_id here');


gr.query();



while(gr.next()) {


var user = gr.getValue('user');


users += ("^ORsys_id=" + user);


}


}


return users;


},


type: 'excludeUser'


};


Hi David Dubuis



script inc.PNGass  group.png




I was not able to call my script include,client callable is active.Is that anything wrong?


You've changed the users variable to a sys_id, change it back to the below:



var users = "sys_id=1234";


you also need to change the users += line as below. The only sys_id you needed to change was the one in the encoded query.



users += ("^ORsys_id=" + user);


Hi David Dubuis



script exclude.pnggroup null.png



I have modified the changes above you mentioned but after that I was not able to view the assignment groups which i shared in the second image.