Autofill Location based on User
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-22-2013 12:15 PM
Hey all.
I am very green when it comes to Service-Now and particularly Java Script (I'm an IT Admin, not a programmer 🙂 but my company has tasked me with setting up some portions of our new Service Now setup.
What I am trying to do is setup a script that will pull a user's location (as we have several offices around the world) once that user is selected.
To be more clear, we have a "leaver" app we are setting up for HR so that when a user leaves the company, they are able to go through a record producer window and select the username (which pulls from sys_user). I have created a Location field within the main "Leaver" window, and am wondering what type of client scripting would be needed to make it so that when the user is selected, it will autopopulate the location they are at within the location field.
We do have this setup for our "incident" request app, but the diffrerence there is that it autopopulates your own user account automatically on opening the app.. so you open the app, and whoever you're logged in as it will autopopulate that user name and at the same time populate their email address and location in lower fields. I looked to see how this functionality works in the client scripting, but again, I'm no programmer so I can't really figure out how to alter that code to make it work for the leaver process.
Would anyone be able to give me a couple pointers? If I'm unclear please let me know and I will try to give more details.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2013 12:13 AM
Hi,
task.location=current.variables."database name of that variable which you have used in your leaver form"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2013 04:42 PM
Just wanted to thank you guys again for your help. This portion of our Leaver process is working as needed now!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-30-2016 04:39 PM
Banging my head against the wall trying to resolve this problem with Catalog Task Location.
Just can't get the trigger to fire!
using a variable set called Requested for to have the user id filled in.
Have tried using 2 different client scripts, but neither works?
Copied it over from Location, but unable to convert it to Catalog Tasks.
On Change Location by User script
Using Catalog Task table
Type on Change
Field Name??? Unable to find a variable set called Requested_for
function onChange(control, oldValue, newValue, isLoading)
{
var a =g_form.getValue('Requested_for');
var gr = new GlideRecord('sys_user');
gr.addQuery('name',a);
gr.query();
if(gr.next())
{
alert(gr.location);
g_form.setValue('location',gr.location);
}
}
function onLoad(control, oldValue, newValue, isLoading)
{
var a =g_form.getValue('Requested_for');
var gr = new GlideRecord('sys_user');
gr.addQuery('name',a);
gr.query();
if(gr.next())
{
alert(gr.location);
g_form.setValue('location',gr.location);
}
}
Added the variable to the Workflow so it should show up.
Added the code the the location.
Variable still refuses to fire?