- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2014 05:22 AM
I want to create a link from left hand pane called My Assets which will show All Assets with the same location as the current logged in user.
I know from Dublin you can download and install something called Simple Separation but we are on Calgary so this won't work for us.
I think I need a business rule like the one for getMyApprovals, but, i'm struggling with the code as I only know a little Javascript
Has anyone been able to write anything like that or can help?
Thank you in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-29-2014 04:28 AM
I managed to get this working by using the following script include:
function getlocationList() {
var user = new GlideRecord('sys_user');
user.get(gs.getUserID());
var answer = new Array();
var i = 0;
answer[i++] = new String(user);
var g = new GlideRecord("cmn_location");
g.addQuery("country", user.location.country);
g.query();
while( g.next())
answer[i++] = new String(g.sys_id);
return answer;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2014 06:42 AM
Got to try !
It is using the getUser Object - http://wiki.servicenow.com/index.php?title=Getting_a_User_Object
I know that gs.getUser().getLocation() you cannot dot walk - gs.getUser().getLocation().country retuns nothing
I guess you can make a filter
where the javascript is javascript:gs.getUser().getCountry();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2014 06:50 AM
No, didn't work on mine as we don't set a Country field on the user record, we use the one off the location
Ive learnt something new today anyway! thank you
Any other ideas to get it working?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2014 07:10 AM
You have to write some code and call the function in the module filter.
Its same as what Julian has posted.
Step 1: Just replace the javascript with the below:
javascript: getlocationList();
Step 2: Create a new script include with the below code in it and make sure your script include looks exactly like the image posted:
Code:
function getlocationList(){
var user = new GlideRecord('sys_user');
user.get(gs.getUserID());
var ret = 'sys_idIN';
var gr = new GlideRecord( 'cmn_location' );
gr.addQuery( 'country', user.location.country );
gr.query();
while( gr.next() ){
ret += gr.sys_id;
}
return ret;
}
and the Image
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-08-2014 01:24 AM
Thank you Ill try it later and let you know
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-09-2014 02:11 AM
HI Santosh
I have done this but unfortunately its not working. I put some debugging in the script to find out the value of sys_idIN, but no value is coming back:
Background message, type:info, message: my ret value is - sys_idIN
I changed the sys_idIN to be user.sys_id and it brought back my user ID, but it still did not work.
What does the sys_idIN mean? What value is meant to be there?
All the help is muchly appreciated
Regards