Issue with gs.getUser().getPreference() method in User table

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2018 06:03 AM
Hello Team,
I am getting an error while setting a filter condition on the User table from a scoped application.
Condition: sys_id is javascript: gs.getUser().getPreference('user.id');
Error: Illegal access to method getPreference(string) in class com.glide.sys.User
I have tried gs.info(gs.getUser().getPreference('user.id')) in background script. There I am getting value without error.
Why this error is coming only in User table? What is other solution for this?
Thanks in advance.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2018 06:05 AM
Please refer to http://www.john-james-andersen.com/blog/service-now/servicenow-user-preferences-server-client-access.html
you will have to do something like
//Set a User Preference
var user = gs.getUser().getUserByID("a2826bf03710200044e0bfc8bcbe5ded");
//Get the value for a specific User's User Preference
var prefVal = user.getPreference("DESIRED_PREFERENCE_NAME");

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2018 08:01 AM
Hello Mike,
I have tried that example in the background scripts in a scoped application. I'm getting warnings in logs, like this
Cannot find function getUserByID in object com.glide.script.fencing.ScopedUser@1b9c6a8.
Can we use getUserByID() in scoped applications?Otherwise, what is the alternate solution?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2018 08:19 AM
Alternate will be create script includes and call that from your scoped app.