- 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:00 AM
Not done this, but what information do you have on the Assets that provides location ?
Is it a reference to the cmn_location table or something else ? (such as you have an IP address and know which location is covered by a specific IP address range)
If it is cmn_location, are your user records also using the same reference field for thier location ?
Basically, once you know what field you are using in your asset and user, you can create a query to look it up.
Do not necessarily need any javascript for this depending on your answers to the location field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2014 06:03 AM
Hi Julian, thanks for your quick response
Yes, both the user record for location and the asset record lookup from the same table cmn_location.
How do I do this without javascript?
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2014 06:19 AM
Assuming you are refering to the Application Navigator on the left
you can add a new entry and it can be a filter
for example, this is our entry for My Raised Open Incidents and provides a quick link to my open incidents
on the same basis, you can create a new entry
Base it on your Asset
where the javascript reads javascript:gs.getUser().getLocation()
You can open a Background script and run this line to see the sys_id of the cmn_location for the user
gs.print(gs.getUser().getLocation());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2014 06:32 AM
Oh wow thats really good thank you! Yes the location brought back was the right one.
From there, am I able to dotwalk do you know as I want to bring back all the assets relating to my country so location.country?