Catalog Item - Populate User ID (user_name)

Jonathan102
Tera Guru

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

2 REPLIES 2

Jaspal Singh
Mega Patron
Mega Patron

Try 

javascript: gs.getUserName();

chrisperry
Giga Sage

Hi there,

This behavior is global and is determined by the specified table's display logic prioritized as below:

  1. A field with display=true in the system dictionary on the lowest sub-table for extended tables.
  2. A field with display=true in the system dictionary on the parent table.
  3. A field named name or u_name.
  4. 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:find_real_file.png

If this answer is helpful please mark correct and helpful!

Regards,

Christopher Perry

If this answer is helpful please mark correct and helpful!

Regards,
Chris Perry