Auto-Populate Impacted User field based on currently logged-in user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2025 02:22 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2025 02:25 AM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2025 02:33 AM
Hello @NishaB
You can configure as below:
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2025 07:09 PM
Hello @NishaB
Steps to auto-populate field based on the currently logged-in user:
- Set Default Value for the Variable:
javascript:gs.getUserID();
Result:
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