- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2022 05:44 PM
We want to enable our user's to decide on their own if/when they change over to the "NEW" UI (Polaris). (Don't understand why this isn't built in like it was for the UI15-16 switchover).
Simple approach to this I thought would be just a UI Action on the user profile. The last challenge is actually forcing the user session to log out. I've been able to kill the session by pulling the current user's record on the v_user_session table. However, once it all runs, the user redirected to the welcome page. Everything else works, but the user experience is still requiring the manual log out even though the session has been deleted.
When IN polaris and the "Toggle UI" is used, it is redirected to welcome.do (in the URL), but the page is blank except for the header.
When IN UI 16 and the "Toggle UI" is used, it is redirected to a sort of "About ServiceNow" page (see screenshot)
UI Action
function confirmUI() {
if (confirm('Click "OK" to update your UI setting. \n\nBe sure to save your work first, as this action will force you to log out for the changes to take effect.'))
gsftSubmit(null, g_form.getFormElement(), "polaris_switch");
}
if (typeof window == 'undefined'){
togglenewUI();
}
function togglenewUI() {
//If preference already set, delete. Otherise create it as 'true' (this script assumes the system default preference is 'false')
var pref = new GlideRecord('sys_user_preference');
pref.addEncodedQuery('name=glide.ui.polaris.use^user='+current.sys_id);
pref.query();
if (pref.next()) {
pref.deleteRecord();
} else {
var addPref = new GlideRecord('sys_user_preference');
addPref.newRecord();
addPref.setValue('name','glide.ui.polaris.use');
addPref.setValue('user',current.sys_id);
addPref.setValue('value','true');
addPref.update();
}
//Kill the current user's session to force them to log in.
var session = new GlideRecord('v_user_session');
session.get('session_id',gs.getSessionID());
session.deleteRecord();
}
Solved! Go to Solution.
- Labels:
-
User Experience and Design
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2022 06:52 PM
Hi,
Can you try this to force logout the user.
action.setRedirectURL('logout.do');
To enable the toggle UI toggle/Switch UI user preferences, you have to set the property
glide.ui.polaris.on_off_user_pref_enabled as true
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2022 06:52 PM
Hi,
Can you try this to force logout the user.
action.setRedirectURL('logout.do');
To enable the toggle UI toggle/Switch UI user preferences, you have to set the property
glide.ui.polaris.on_off_user_pref_enabled as true
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2022 05:28 AM
Worked like a charm --> action.setRedirectURL('logout.do');
But now it's not needed because you've pointed out the property to enable the toggle.
Thanks!