Auto fill user fields in form

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2009 01:04 PM
I have a record producer setup to create a new project. Currently I am pulling the creator by using javascript:gs.getUserID();. What I would like to do is auto complete other forms from that userID such as phone, email, etc.
I've attempted to discover how we did it for our incident form, but I cannot seem to piece it together.
(Incident form auto populates title and phone number after entering caller name).
Thanks,
Steve
- Labels:
-
Orchestration (ITOM)
-
Service Mapping

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2009 01:06 PM
I should clarify... auto complete other fields in the project ticket, not forms.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2009 02:33 PM
Greetings Hill,
You should be able to auto-complete some sys_user fields if you are able to add them to forms through a reference field.
1.Add a reference field to your form that references Users[sys_user].
2.Once you have that field on your form, right-click your form header and select Personalize -> Form Layout.
3.Select your field from "Available" bucket. In the middle of the two buckets a PLUS icon should appear.
4.Click on it, it should expand your reference field and show all fields available from your User[sys_user] table.
5.Now you can start adding fields from User on to your form such as Phone, Email, etc.
6.Save your changes.
Let me know if it works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2009 06:50 PM
Stranger, using related fields on a form view only works on records, not record producers. You'd need a catalogue client script, or a business rule on submit.
Similar to incident location population scripts, you could easily modify the one below, or the "(BP) Set Location to User" that came with the Incident plugin for the winter release.
function onChange(control, oldValue, newValue, isLoading) {
var location = g_form.getValue('location');
if ((!(isLoading && location != '')) && newValue != '') {
var userRec = g_form.getReference('caller_id');
g_form.setValue('location',userRec.location);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2009 07:13 PM
Update: I forgot to mention you could use the built-in User Object functions for what you need.
http://wiki.service-now.com/index.php?title=Getting_a_User_Object
myUserObject.getFirstName()
myUserObject.getLastName()
myUserObject.getEmail()
myUserObject.getDepartmentID()
myUserObject.getCompanyID()
myUserObject.getLanguage()
myUserObject.getManagerID()
So to set the Department field of a record producer, in default value use
javascript:gs.getUser().getDepartmentID()
The above list doesn't include phone numbers etc though, but should give you a head start. You might consider writing a custom global business rule and call it from the field, but that functionality is quite advanced.