- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2018 05:29 AM
I'm trying to set a default value on a reference field called "u_director_name". When a user creates a Change Request I want the Director value [u_director] from their User record to pass to "u_director_name".
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2018 06:09 AM
Looks like maybe you've got some security settings getting in the way. You'll probably need to create a script include with the 'gs.getUser().getRecord().getValue('u_director_name');' line I gave you before. Then you can call your script include in your default value instead. It's really simple to do. Just set it up as shown here.
https://community.servicenow.com/community?id=community_question&sys_id=5ea11b6ddbdcdbc01dcaf3231f96197e

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2018 05:33 AM
This article shows how you can do this for all sorts of things.
https://www.servicenowguru.com/scripting/user-object-cheat-sheet/
As long as 'u_director' and 'u_director_name' reference the same table, you should be able to simply place this as the default value in the 'Default value' field on the 'u_director' field dictionary.
javascript:gs.getUser().getRecord().getValue('u_director_name');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2018 05:33 AM
Hi Lisa,
So you want the director name field which is a reference field to have default value with the logged in user's director.
set it in default value at dictionary level. is there a field on user table which stores the director
javascript:gs.getUser().getRecord().getValue('<userFieldStoringDirector>');
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2018 05:50 AM
Mark,
I'm getting an error, "Error Message Illegal access to method getRecord() in class com.glide.sys.User". Both of my fields reference the sys_user table.
I will also add that the u_director_name field is hidden until a different field is set on the Change Request.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2018 05:54 AM
Please post screenshots of the error message on the form...as well as your dictionary entry showing the default value.