Catalog Item - Populate User ID (user_name)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2022 12:55 PM
Hi all,
I have a catalog item that I am trying to get to auto populate the the User ID (user_name) and I can't get it to work. I am already auto populating the logged in users name with javascript:gs.getUserID(); in the default of the variable.
Any suggestions on how to pull in the User ID to the form?
Thanks,
Jonathan Hinkle

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2022 01:05 PM
Try
javascript: gs.getUserName();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2022 01:06 PM
Hi there,
This behavior is global and is determined by the specified table's display logic prioritized as below:
- A field with display=true in the system dictionary on the lowest sub-table for extended tables.
- A field with display=true in the system dictionary on the parent table.
- A field named name or u_name.
- The Created on field of the referenced record.
In your example of sys_user table, that is why the sys_user's name field value is showing up in the reference variable. If you want to show user_name instead, you should set Display = true for the user_name column definition of sys_user table -- you should be cautious in using this method however, as this will have global impacts to a referenced sys_user record being displayed anywhere within ServiceNow:
If this answer is helpful please mark correct and helpful!
Regards,
Christopher Perry
Regards,
Chris Perry