- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2015 12:38 PM
Hi all,
I'm trying to populate a variable on a catalog item based on the Request For widget on a catalog item.
I currently have a script that pulls the location of the person logged into ServiceNow into a variable but that may be a service desk person and the request may be for a person in a different location. I want it to pull the location of this person.
- I've added the Request For widget to the catalog home page
- I have a variable set called location and it pulls the location of the person submitting the request (the person logged into ServiceNow). The default value for this variable set is javascript: gs.getUser().getRecord().getValue('location')
Any ideas on how to update this script to pull the location of the person listed in the request for rather than the person who is logged in? Thanks so much.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2015 01:35 PM
Kristina,
You need to create a script include like this:
Name : getLocation
Script:
function getLocation()
{
var cart = new GlideRecord('sc_cart');
cart.addQuery('user',gs.getUserID());
cart.query();
if(cart.next())
{
return cart.requested_for.location;
}
return '';
}
Now, have the default value as javascript:getLocation()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2015 12:44 PM
Maybe javascript:current.variables.request_for.getRecord().getValue('location')?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2015 12:45 PM
Thanks Mike. Unfortunately this didn't work. The variable 'location' is not pulling anything. That's the issue I'm running into
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2015 12:56 PM
Maybe javascript:current.variables.request_for.location ? As this is a reference to the user table it should work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2015 12:54 PM
Probably going to have to do an AJAX call to pull the information back. The gs.getUser() is in the session, so it is easily accessible. This is a client interaction with a server lookup, so I think AJAX is the way to go.