g_user.userName returns a hash, the id, not the username. What causes this?

tdQ1w7xO6k
Giga Contributor

I hope to ask this in a general sense to answer what causes this. When this happens, what usually is the cause? Are you supposed to dot-walk further after g_user.userName?

1 ACCEPTED SOLUTION

Allen Andreas
Administrator
Administrator

Hi,

That will return the user_name field value from the sys_user table. Which is labeled as the "User ID" on that record. If the user_name (User ID) field also contains the sys_id...then of course it'll share that value back. You can review the sys_user record in question for additional information.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

3 REPLIES 3

Willem
Giga Sage
Giga Sage

Hi,

 

g_user.userName should return the user name (see below).

If this is not happening for your case, please share more info and the script you use. There might be something else causing the issue in that case.

find_real_file.png

Reference: https://developer.servicenow.com/dev.do#!/learn/learning-plans/rome/new_to_servicenow/app_store_lear...

Willem
Giga Sage
Giga Sage

Things to check:

  • Can you check what the display value for your users is? Have you changed this to the ID instead of the user name? Not sure that would cause it, but without additional information you can check if setting that to the user name solves this issue.
  • What is the hash value you get? Is it the sys_id? Can you share this for an example user?
  • Where are you using this script? Do you see anything in the (system/browser) logs?

 

Allen Andreas
Administrator
Administrator

Hi,

That will return the user_name field value from the sys_user table. Which is labeled as the "User ID" on that record. If the user_name (User ID) field also contains the sys_id...then of course it'll share that value back. You can review the sys_user record in question for additional information.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!