- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @Uthman ,
Where do you want to auto populate Native view or catalog item?
You can set default value to:
javascript: gs.getUserID();
Thanks
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Set the Default Value to javascript:gs.getUserID()
.gs.getUserID() gets the Sys ID of the currently logged-in user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Below approaches
1) Recommended - Default value in dictionary
javascript: gs.getUserID();
OR
2) If field is on form then you can use onLoad client script
g_form.setValue('opened_by', g_user.userID);
OR
3) Display business rule on your table
current.opened_by = 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
3 weeks ago
Hi @Uthman ,
you can set the default value in the dictionary to:
javascript:gs.getUserID()
That will ensure it always takes the currently logged-in user. Alternatively, you can use a client script (g_form.setValue('opened_by', g_user.userID)) if you want to handle it on the form.
Thanks & Regards,
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution so others can benefit as well.
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution so others can benefit as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @Uthman
Use javascript:gs.getUserID();
in the Default Value field of a catalog variable or reference field or Onload client script (g_form.setValue('requested_for', g_user.userID);)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @Uthman ,
1. Default value (easy way):
Go to the field’s dictionary entry.
Set default value to:
gs.getUserID()
New records will auto-fill with the current user.
2. Business Rule (always fills):
Create a Before Insert rule:
if (!current.opened_by)
current.opened_by = gs.getUserID();
This makes sure the field is automatically set to whoever is logged in.