The Zurich release has arrived! Interested in new features and functionalities? Click here for more

gs.getUser().getPreference() does NOT return the "value"

xiaix
Tera Guru

According to This Docs Page, it's saying that gs.getUser().getPreference() returns a "String".  It does not.

So in a widget, I have the following code in the Server Script part:
find_real_file.png

and this in my Client Script:
find_real_file.png

I have a user preference on the sys_user_preference table:

find_real_file.png

 

When I preview the widget, I get this in my console:

find_real_file.png

 

 

Now if I do something insanely ridiculous like this:

find_real_file.png

then fine, I get what I'm looking for.... however, I shouldn't have to do all this to when .getPreference() should be doing this for me.

 

 

1 ACCEPTED SOLUTION

ChrisBurks
Mega Sage

If you're not in a scoped app, if you're creating that preference on your own profile try logging out then back in. The preference should then be applied.

View solution in original post

10 REPLIES 10

Why would you think that gs.getUser().getPreference() can't be used in the "Global" scope?

docs.servicenow.com >> GlideUser shows method getPreference() for scoped but not for global,

but appears you are using it successfully, so are the docs incorrect?

ChrisBurks
Mega Sage

If you're not in a scoped app, if you're creating that preference on your own profile try logging out then back in. The preference should then be applied.

Wow... that was it.  It was a recently created preference.  After logging out and then back in, everything worked.

So.... any way to set a user preference and have it available immediately without needing them to log out/in ?

Nope, sorry don't know that one. Let me know if you find out though.