Hide user records in the Assigned to field.

NARASIMHA REDD5
Tera Contributor

Hi Team,

Based on logged in user I want to hide the user records in Assigned to field.

Example: Which users are in Indian county or Group is -xxx- that user select a --Y-- group in  the assignment group field. we  hide few users in  Assigned to those are in -Y- Group. How can i achieved.

 

 

Thanks

2 ACCEPTED SOLUTIONS

Shivam Techlene
Tera Guru

Hi @NARASIMHA REDD5 ,

 

As per my understanding towards your requirement, you need lookup to only those users in assigned to field who are either member of current assignment group OR whose country is not same as current logged in user. If this is the case, then you can utilize reference qualifier for this. Please use the given code in the reference qualifier of assigned to field.

Steps to Reproduce:

Open dictionary of assigned_to field and under reference specification section, select "Advanced" in "Use reference qualifier" field and write the below code in "Reference qual" field:

 

 

 

javascript:'country' != gs.getUser().country^ORgs.getUser().isMemberOf(current.assignment_group.name);

You can change the conditions as per your exact requirement or let me know if you need any specific modifications.

Please mark my response as helpful and correct if it helps to resolve your requirement.

 

Thanks & Regards,
Shivam Jaiswal

View solution in original post

Hi @NARASIMHA REDD5 there are 2 ways to do this, 1st way Shivam has shared the response , another way you can create a script include to check the users and call the script include in reference qualifier of incident assigned to field by doing dictionary override.

 

Script Include:

checkUser: function(grp) {
        gs.info(grp);
        var arrList = [];
        var gr = new GlideRecord('sys_user_grmember');
        gr.addQuery('group', grp);
      //  gr.addEncodedQuery('user.location!=f69521b437d0200044e0bfc8bcbe5d6e');
        gr.query();
        while (gr.next()) {
            if(gr.user.location !='f69521b437d0200044e0bfc8bcbe5d6e')
            {
            arrList.push(gr.user.sys_id.toString());
            }

        }
        gs.info( arrList.join(','));
        return 'sys_idIN' + arrList.join(',');
    },
HarishKM_0-1707183201957.png

 

 

HarishKM_1-1707183241523.png

call the script include in reference qualifier as below

javascript: new demoUtils().checkUser(current.assignment_group);

HarishKM_2-1707183273768.png

 

Regards
Harish

View solution in original post

7 REPLIES 7

Hi @NARASIMHA REDD5 there are 2 ways to do this, 1st way Shivam has shared the response , another way you can create a script include to check the users and call the script include in reference qualifier of incident assigned to field by doing dictionary override.

 

Script Include:

checkUser: function(grp) {
        gs.info(grp);
        var arrList = [];
        var gr = new GlideRecord('sys_user_grmember');
        gr.addQuery('group', grp);
      //  gr.addEncodedQuery('user.location!=f69521b437d0200044e0bfc8bcbe5d6e');
        gr.query();
        while (gr.next()) {
            if(gr.user.location !='f69521b437d0200044e0bfc8bcbe5d6e')
            {
            arrList.push(gr.user.sys_id.toString());
            }

        }
        gs.info( arrList.join(','));
        return 'sys_idIN' + arrList.join(',');
    },
HarishKM_0-1707183201957.png

 

 

HarishKM_1-1707183241523.png

call the script include in reference qualifier as below

javascript: new demoUtils().checkUser(current.assignment_group);

HarishKM_2-1707183273768.png

 

Regards
Harish

Shivam Techlene
Tera Guru

Hi @NARASIMHA REDD5 ,

 

As per my understanding towards your requirement, you need lookup to only those users in assigned to field who are either member of current assignment group OR whose country is not same as current logged in user. If this is the case, then you can utilize reference qualifier for this. Please use the given code in the reference qualifier of assigned to field.

Steps to Reproduce:

Open dictionary of assigned_to field and under reference specification section, select "Advanced" in "Use reference qualifier" field and write the below code in "Reference qual" field:

 

 

 

javascript:'country' != gs.getUser().country^ORgs.getUser().isMemberOf(current.assignment_group.name);

You can change the conditions as per your exact requirement or let me know if you need any specific modifications.

Please mark my response as helpful and correct if it helps to resolve your requirement.

 

Thanks & Regards,
Shivam Jaiswal

Hi @NARASIMHA REDD5 ,

 

Did you get a chance to try this one?

 

Kindly mark my response as helpful and correct if it helps to your requirement.

 

Thanks & Regards,
Shivam Jaiswal