- 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 06:40 AM
You can use a script action on login to add some data to the current session data. If you're looking to get at the data from a client script, that's a pretty good bet.
Session Client Data - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2015 10:46 AM
Brad,
Is there no better way for me to set the default value of this field to the value of the current users u_data field on sys_user?
It seems like I should be able to access the u_data field if I can get the current user (gs.getUser()).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2015 11:35 AM
You need to create a client callable script include in which you could glide record user table and return u_data then call the script include in default value as follow
javascript:script_include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2015 11:45 AM
Gupreet,
Using a script include makes sense. Do you have any advise on how to determine the current user within the script include, or is there a way to pass gs.getUser() to the script include?
Thanks!