if want to restrict assigned to field based on caller id location

satya609
Tera Contributor

If caller id location is matches with the users in the  assignment group then i want to see those users in the assigned to field. 

1 ACCEPTED SOLUTION

Sarthak Kashyap
Mega Sage

Hi @satya609 ,

 

I tried your problem in my PDI and it works fine for me please check below solution 

 

navigate to your incident record right click on assigned_to field and click on Configure dictionary 

SarthakKashyap_0-1764427693949.png

In related list of dictionary override check for incident record and open it

SarthakKashyap_1-1764427771779.png

In Reference Qualifier add below script 

SarthakKashyap_2-1764427797497.png

 

javascript: new global.checkLocationCaller().callerLocationCheck(current.caller_id, current.assignment_group);

 

Create new Script Include and add below code 

var checkLocationCaller = Class.create();
checkLocationCaller.prototype = {
    initialize: function() {},

    callerLocationCheck: function(inc_caller, inc_group) {
        gs.log("SI Called checkLocationCaller");

        var callerCountry = "";
        var u = new GlideRecord("sys_user");
        if (u.get(inc_caller) && u.location && u.location.country)
            callerCountry = u.location.country.toString();

        var result = [];
        var gr = new GlideRecord("sys_user_grmember");
        gr.addQuery("group", inc_group);
        gr.addQuery("user.active", true);
        gr.addQuery("user.location.country", callerCountry); // dot-walk filter
        gr.query();

        while (gr.next()) {
            result.push(gr.user.toString()); // only user sys_id
        }

        return "sys_idIN" + result.join(",");
    },

    type: 'checkLocationCaller'
};

 

SarthakKashyap_4-1764427872614.png

 

 

Result: 

Caller Location Country is USA

SarthakKashyap_5-1764427924777.png

 

In Assignment Group Below users location country is USA

SarthakKashyap_6-1764427967553.png

 

So When I click on Assigned To it will show me users which country is USA

SarthakKashyap_7-1764427999681.png

 

 

Please mark my answer correct and helpful if this works for you

Thanks and Regards,
Sarthak

 

 

View solution in original post

6 REPLIES 6

Sarthak Kashyap
Mega Sage

Hi @satya609 ,

 

I tried your problem in my PDI and it works fine for me please check below solution 

 

navigate to your incident record right click on assigned_to field and click on Configure dictionary 

SarthakKashyap_0-1764427693949.png

In related list of dictionary override check for incident record and open it

SarthakKashyap_1-1764427771779.png

In Reference Qualifier add below script 

SarthakKashyap_2-1764427797497.png

 

javascript: new global.checkLocationCaller().callerLocationCheck(current.caller_id, current.assignment_group);

 

Create new Script Include and add below code 

var checkLocationCaller = Class.create();
checkLocationCaller.prototype = {
    initialize: function() {},

    callerLocationCheck: function(inc_caller, inc_group) {
        gs.log("SI Called checkLocationCaller");

        var callerCountry = "";
        var u = new GlideRecord("sys_user");
        if (u.get(inc_caller) && u.location && u.location.country)
            callerCountry = u.location.country.toString();

        var result = [];
        var gr = new GlideRecord("sys_user_grmember");
        gr.addQuery("group", inc_group);
        gr.addQuery("user.active", true);
        gr.addQuery("user.location.country", callerCountry); // dot-walk filter
        gr.query();

        while (gr.next()) {
            result.push(gr.user.toString()); // only user sys_id
        }

        return "sys_idIN" + result.join(",");
    },

    type: 'checkLocationCaller'
};

 

SarthakKashyap_4-1764427872614.png

 

 

Result: 

Caller Location Country is USA

SarthakKashyap_5-1764427924777.png

 

In Assignment Group Below users location country is USA

SarthakKashyap_6-1764427967553.png

 

So When I click on Assigned To it will show me users which country is USA

SarthakKashyap_7-1764427999681.png

 

 

Please mark my answer correct and helpful if this works for you

Thanks and Regards,
Sarthak

 

 

Wow, great job 👍  @Sarthak Kashyap  

 

Regards,

Mohammed Zakir

Hi @satya609 ,

 

Did you tried my solution ? If it works for you so Please mark my answer correct and helpful.

 

Thanks and Regards,

Sarthak