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

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Kumar - Do you have this setup in personal dev instance URL? If yes, please share the link...

Hi Pradeep,

 

Yes I am working on PDI. I do not understand what you will do with just link without credentials. For reference I have attached XML of the record too. However PFB the link

https://dev82723.service-now.com/nav_to.do?uri=sys_script_include.do?sys_id=95aa639bdb9f101061122706ca96192f

 

Thanks

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'
};

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Let me know if that answered your question. If so, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.