Show incidents by current logged in user location

Evan2
Kilo Guru

Hi All,

 

I am trying to filter the incidents by logged in user location, I am trying to use script include and a dynamic filter to achieve this. But i am unable to filter the logged incidents with currenty logged in user location. PFB the details-

 

Script Include 

var getMyUserInfo = Class.create();
var answer = '';
myConditionCheck.prototype =
{
initialize: function()
{
},
myRegion : function()
{
var user = new GlideRecord('sys_user');
user.addQuery('sys_id',gs.getUserID());
user.query();
// if (user.get(gs.getUserID())
//if(user.getUserID())
if(user.next())
{
//var location = gs.getUser().getLocation();
//return user.location;
answer = user.location;
return answer;
}
return;
},
type: 'myConditionCheck'
};

 

 

Dynamic Filter

find_real_file.png

Please help me !!

 

Thanks,

Kumar Nandan

1 ACCEPTED SOLUTION

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi,

The reason I have asked instance URL so that I can fix it directly in your instance. Please check your instance. I have created a new script include and it is working fine now.

var getMyUserInfo = Class.create();
getMyUserInfo.prototype = {
    initialize: function() {},
    myRegion: function() {
		var answer;
        var user = new GlideRecord('sys_user');
        user.addQuery('sys_id', gs.getUserID());
        user.query();
        // if (user.get(gs.getUserID()) 
        //if(user.getUserID())
        if (user.next()) {
            //var location = gs.getUser().getLocation();
            //return user.location;
            answer = user.location;
            return answer;
        }
    },

    type: 'getMyUserInfo'
};

View solution in original post

8 REPLIES 8

HI Pradeep,

 

Thank you so much. Yes you did it. 🙂 🙂 

 

Regards,

Kumar Nandan

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

You are very welcome.

Alex307
Kilo Guru

What does 'gs.getUser().getLocation()' return?

Have you tried using that directly in your arguments like 'location=javascript:gs.getUser().getLocation()' ?

Also 'Client Callable' should be checked to true.