- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2024 09:23 AM
Hello,
I have a requirement to auto fill the user fields based on a reference field on our table. I am still missing something because it shows the answer of Null and I am not see why. Below are my two scripts.
AJAX / Script Include:
Client Script:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2024 09:54 AM
Here is the final client script that worked and ended up needed a condition added that I didn't realize until I was testing.
Client Script:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2024 10:42 AM
@Annette Kitzmil Update the script include method as follows.
getUserLanID: function() {
var LanID = this.getParameter('LanID');
var openedBy = new GlideRecord('sys_user');
openedBy.addQuery('user_id', LanID);
openedBy.query();
if (openedBy.next())
return openedBy.getValue('name');
},
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2024 09:54 AM
Here is the final client script that worked and ended up needed a condition added that I didn't realize until I was testing.
Client Script:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2024 10:15 AM
Hi there,
Any reason you are doing this with an onLoad Client Script and not with just using default value on the field?
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field