- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2017 06:43 PM
Hi all,
I've got a record producer that I've built to create records in a custom table extended from Task. The records have some fields that I want to populate automatically when created by the record producer that pull values from the user record of the person submitting the record producer.
Having trouble with the script in the record producer to do this.
Can I simply dot walk into the users record? Or do I have to set up a Gliderecord query?
example...one field on the form is "location", which is a field on the sys_user table.
thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2017 09:42 AM
it actually was simple enough to just do a GlideRecord, I did this script on the record producer and it works perfectly.
//Set the location and region on the generated record
user = gs.getUserID();
var userDetails = new GlideRecord('sys_user');//table where desired variable lives
userDetails.addQuery('sys_id',user);
userDetails.query();
if(userDetails.next())
{
current.location = userDetails.location;
current.region = userDetails.location.u_region;//name of field with info you want to grab
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2017 10:51 PM
'parent table name' is generally sys_user. i.e Where you want to get the location with reference of user record.
grParent.get(g_form.getValue('parent') :: ;parent' means userid or name from sys_user table (Basically unique filed in the record).
Hit Correct/Endoresers/Like/Helpful as when felt
@Lakshmaiah
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2017 12:08 AM
User following call back method to get the location value using Catalog Client Scripts.
function onChange(control, oldValue, newValue, isLoading) {
var caller = g_form.getReference('u_contact', getLocation);
function getLocation(caller){
//jslog("city::"+caller.city);
if(caller.city){
g_form.setValue("u_location", caller.city);
}
}
}
PS: Hit like, Helpful or Correct depending on the impact of the response .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2017 09:42 AM
it actually was simple enough to just do a GlideRecord, I did this script on the record producer and it works perfectly.
//Set the location and region on the generated record
user = gs.getUserID();
var userDetails = new GlideRecord('sys_user');//table where desired variable lives
userDetails.addQuery('sys_id',user);
userDetails.query();
if(userDetails.next())
{
current.location = userDetails.location;
current.region = userDetails.location.u_region;//name of field with info you want to grab
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2017 09:46 AM
how about using in this way,
var myUserObject = gs.getUser();
current.location = myUserObject.getLocation()
reference: http://wiki.servicenow.com/index.php?title=Getting_a_User_Object#gsc.tab=0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2017 09:50 AM
hello Shishir,
thanks for the reply...I plugged your script in and it doesn't populate the "location" field on the record...is there more to it or should that work just like that?