- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2015 05:58 AM
We have a custom user attribute, it is a field called u_data containing a string.
I want to set a catalog variable field to default to the value of <current user>.u_data, however it appears that gs.getUser() can only access properties that have functions defined to return them (Getting a User Object - ServiceNow Wiki). Is there a way to define a function that returns this custom property to client scripts?
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2015 03:00 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2015 11:51 AM
You can just use gs.getUser() inside of your script include. You could also grab the gliderecord for the user in the default value like:
javascript: var user = new GlideRecord('sys_user'); user.get(gs.getUserID()); user.u_data;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2015 11:51 AM
1. Create a client callable script include getData having following type of code
function getData(){
var gr = new GlideRecord('sys_user');
gr.get(gs.getUserID());
return gr.u_data ;
}
default value:
javascript:getData()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2015 03:00 PM
have you tried
gs.getUser().getRecord().getValue('u_data');

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-03-2015 12:44 PM
Clean and easy answer. It returns a GlideMemoryRecord which is cached at login so just be aware of that possible limitation if data being retrieved could change during a user's session.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-03-2016 12:08 AM
Have the below code in Default Value of the Variable. This will auto populate with the current user logged in. The Reference should point to the User Table (sys_user)
javascript:gs.getUserID()