
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2020 01:46 PM
I've been working on a scoped application that redirects users based on the form view. I need to somehow reset the form view after that so the next time the user signs in the view is back to default.
I tried just using gs.getUser().setPreference('x_bonm_bip_data_policy_term.view', 'default') and gs.getUser().setPreference('x_bonm_bip_data_policy_term.view', '') in background script and both worked, however if I use them on a Script Action triggering from the session.established event (which happens when the user signs in) they simply don't work.
I have tested with logs and the script action is actually being triggered, but that setPreference does nothing. Any idea why might this be happening?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2020 07:51 PM
Hey Ivar Donado,
Refer the thread it might help you:
And also go through the link:
Mark Correct and Helpful on the basis of Impact!!!
Best Regards,
Namrata.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2020 07:19 PM
Hi, the docs only show entries for clientSide
https://developer.servicenow.com/dev.do#!/search/madrid/All/setPreference
and it may be that serverSide setPreference is only available in global scope?
You might be able to work around it with a glidequery lookup\update to set your values directly on sys_user_preference table.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2020 07:22 AM
I thought so after making this question. I tried doing a query and...weirdly enough I can't even get the record count (.getRowCount()) from the action script, but I do get it from the background script. This looks more like an access issue from the action script to the user preferences table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2020 07:51 PM
Hey Ivar Donado,
Refer the thread it might help you:
And also go through the link:
Mark Correct and Helpful on the basis of Impact!!!
Best Regards,
Namrata.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2020 07:33 AM
I had attempted to use those methods (using the user id). And even tried a query through gliderecord just to check if I could delete or modify the preference records but I can't even get the amount of records found with getRowCount() there (it always returns zero). I assume there's some kind of access restriction to the preferences table from action scripts as every script I come up with works when run as background script.