How to set assignment group based on logged in user region

sriram7
Tera Contributor

Hello,

 

I have logged into the incident form, my region is india, in Assignment group field it needs to show only india groups list. 

 

If some x person logs in, he's region is empty, in that case it needs to show all the assignment groups list.

 

if some y person logs in. his region is london, in that case it needs to show only london assignment groups list

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@sriram7 

you can use advanced ref qualifier on the assignment group field using the Dictionary override

what did you start with and where are you stuck?

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Runjay Patel
Giga Sage

Hi @sriram7 ,

 

Follow below steps.

1. Go to dictionary override of assignment group. Add the reference qualifier. 

RunjayPatel_0-1738040963120.png

 

javascript: "sys_idIN"+ new getMyGroup().getGrps();

 

2. create one script include name getMyGroup with function getGrps().

use below code.

var getMyGroup = Class.create();
getMyGroup.prototype = {
    initialize: function() {},
    getGrps: function() {
        var userSysId = gs.getUserID();
        var userCountry = '';
        var userRecord = new GlideRecord('sys_user');
        if (userRecord.get(userSysId)) {
            userCountry = userRecord.country;
        }
        var gr = new GlideRecord('sys_user_grmember');
        gr.addQuery('u_country', userCountry);
        gr.query();
        while (gr.next()) {
            groupSysIds.push(gr.group.toString());
        }

        return groupSysIds;

    },

    type: 'getMyGroup'
};

RunjayPatel_1-1738041122645.png

 

3. create one filed called u_country in group table and map the country which they belongs to. Use save value like country filed on user table.

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------