Auto-Populate Impacted User field based on currently logged-in user

NishaB
Tera Expert

Hi,

In the record producer, I have a field called Impacted User field. I want this to auto-populate based on the currently logged-in user. How to do this? Please give a script for this.

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@NishaB 

simply use this in default value of that reference variable pointing to sys_user

javascript: gs.getUserID();

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Viraj Hudlikar
Tera Sage
Tera Sage

Hello @NishaB 

 

You can configure as below:

VirajHudlikar_0-1739788360729.png

VirajHudlikar_1-1739788372992.png

 

VirajHudlikar_2-1739788387967.png

 

If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.

 

Thanks & Regards
Viraj Hudlikar.

 

Juhi Poddar
Kilo Patron
Kilo Patron

Hello @NishaB 

Steps to auto-populate field based on the currently logged-in user:

  • Set Default Value for the Variable:

 

javascript:gs.getUserID();

 

 

JuhiPoddar_0-1739847147754.png

Result:

JuhiPoddar_1-1739847243114.png

Note:

  • This method works when the variable is of reference type pointing to the sys_user table.
  • If the variable is of text type, a Client Script is required to fetch and set the user's name.

Hope this helps!

 

"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"

 

Thank You
Juhi Poddar