Some PDIs are currently unavailable, and PDI actions are paused. View the latest updates here. Read More

hide user in dropdown

WeighedBrass95
Tera Contributor

WeighedBrass95_0-1783348924520.png

I want to hide a user that is in the "Assigned to" group. Since they are part of a group in "Assignment group", I am not able to hide them without removing them from the group all together. How do I go about changing this? 

2 REPLIES 2

Ankur Bawiskar
Tera Patron

@WeighedBrass95 

the assigned to field must be having dependency on the Assignment group and hence not directly possible

2 approaches

1) remove that dependency and use advanced reference qualifier and in the script include get all members of that group excluding that user and return those sysids

OR

2) keep the dependency as it is, use onSubmit client script or onChange client script and check if the selected user is the one which you don't want to be selected, if yes then throw field message with error

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Tanushree Maiti
Tera Patron

Hi @WeighedBrass95 

 

If you have existing Reference Qualifier , update it . If not , follow this steps:

 

1)Navigate to the incident form,

  • right-click the Assigned to field label, and select Configure Dictionary.
  • Scroll to the Reference Qualifier section at the bottom
  • Update the qualifier to call a Script Include that evaluates the chosen Assignment group and returns a filtered list of user Sys IDs:
    javascript:

new UpdateAssignedTo().excludeGroupMembers(current.assignment_group);

 

2)

Navigate to System Definition > Script Includes->Click New

 

var UpdateAssignedTo = Class.create();

UpdateAssignedTo.prototype = {

    initialize: function() {},

 

    excludeGroupMembers: function(groupId) {

        var userIds = [];

        if (!groupId) return "";

 

        var grMember = new GlideRecord('sys_user_grmember');

        grMember.addQuery('group', groupId);

        grMember.query();

        while (grMember.next()) {

            if (grMember.user.sys_id.toString() != 'YOUR_TARGET_USER_SYS_ID_HERE') // Exclude the specific user's sys_id here or better use sys_properties

          {

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

            }

        }

        return "sys_idIN" + userIds.join(',');

    },

    type: 'UpdateAssignedTo'

};

 

 

 

 

 

Refer : https://www.servicenow.com/community/developer-forum/i-want-to-remove-the-the-user-from-assigned-to-...

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti