- 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-09-2014 02:17 AM
I also put another info msg in to find out what gr.sys_id was and it was a sys ID relating to a random address
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-09-2014 02:44 AM
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;
}
Some correction.
make sure the location have a valid country name.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-09-2014 03:46 AM
It still brings back a random address.
Could it be because the country field is a free text field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-09-2014 03:52 AM
var user = new GlideRecord('sys_user');
user.get(gs.getUserID());
gs.log(user.sys_id.toString());
var ret = 'sys_idIN';
var gr = new GlideRecord( 'cmn_location' );
gr.addQuery( 'country', user.location.country );
gr.query();
gs.log('Count:'+gr.getRowCount());
while( gr.next() ){
ret += gr.sys_id.toString()+',';
}
gs.log('return:'+ret);
Run this in background script and send me the result.
to use background script, you should be security admin(Elevated role)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-09-2014 04:11 AM
This brought back a Sys_id for Me Correct
count 430 (this is correct there are 430 locations with the country as united Kingdom (my country location)
then listed the sys_ids relating to the country I can gather
I clicked the link, but, nothing appears in the list and the query string shows location as blank
Getting there though:)