- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-18-2019 11:58 AM
There is a scoped application for certain role users (Senior managers) . The managers would like to see a reporting dashboard as their homepage. There are many users with such role and the development team does not have admin access to the Prod. So, manual update to user preference is out of question.
I searched posts and found a link below
The team faced challenges.
1. The BR needs to implemented on a global scope table sys_user_has_role and the business side would not permit to add more configurations to the global scope. So, we wanted to implement a fix script.
2. The fix script states to use a page's sys_id but we do use "homepage" but a Dashboard [pa_dashbaord] and we cannot just put the dashboard sys_id. Can we?
3. Due to the deadline and the QA is under way, we cannot rebuild a homepage now.
Please help.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2019 02:48 PM
Try the below script
var iRole = new GlideRecord('sys_user_has_role');
iRole.addQuery('role', 'e1a3c4f8df93210068c37a0d3df26321');
iRole.query();
while(iRole.next()) {
var page = new GlideRecord('sys_user_preference');
page.addQuery('name', 'com.snc.pa.ui.preferences_dashboards');
page.addQuery('user', iRole.user);
page.query();
if(page.next()) {
page.value = '{"last":"a64b7031d7201100b96d45a3ce610335"}';
page.description = 'Set by a fix script';
page.update();
}
else {
page.description = 'Set by a fix script';
page.name = 'com.snc.pa.ui.preferences_dashboards';
page.type = 'string';
page.value = '{"last":"a64b7031d7201100b96d45a3ce610335"}';
page.user = iRole.user;
page.insert();
}
}
And if idea is to run the script only once
use the below script
var iRole = new GlideRecord('sys_user_has_role');
iRole.addQuery('role', 'e1a3c4f8df93210068c37a0d3df26321');
iRole.query();
while(iRole.next()) {
var page = new GlideRecord('sys_user_preference');
page.description = 'Set by a fix script';
page.name = 'com.snc.pa.ui.preferences_dashboards';
page.type = 'string';
page.value = '{"last":"a64b7031d7201100b96d45a3ce610335"}';
page.user = iRole.user;
page.insert();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2019 02:48 PM
Try the below script
var iRole = new GlideRecord('sys_user_has_role');
iRole.addQuery('role', 'e1a3c4f8df93210068c37a0d3df26321');
iRole.query();
while(iRole.next()) {
var page = new GlideRecord('sys_user_preference');
page.addQuery('name', 'com.snc.pa.ui.preferences_dashboards');
page.addQuery('user', iRole.user);
page.query();
if(page.next()) {
page.value = '{"last":"a64b7031d7201100b96d45a3ce610335"}';
page.description = 'Set by a fix script';
page.update();
}
else {
page.description = 'Set by a fix script';
page.name = 'com.snc.pa.ui.preferences_dashboards';
page.type = 'string';
page.value = '{"last":"a64b7031d7201100b96d45a3ce610335"}';
page.user = iRole.user;
page.insert();
}
}
And if idea is to run the script only once
use the below script
var iRole = new GlideRecord('sys_user_has_role');
iRole.addQuery('role', 'e1a3c4f8df93210068c37a0d3df26321');
iRole.query();
while(iRole.next()) {
var page = new GlideRecord('sys_user_preference');
page.description = 'Set by a fix script';
page.name = 'com.snc.pa.ui.preferences_dashboards';
page.type = 'string';
page.value = '{"last":"a64b7031d7201100b96d45a3ce610335"}';
page.user = iRole.user;
page.insert();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2019 02:50 PM
Hey
Any update on this?
If one of the responses provided above answered your question, please mark the response as correct so that others in the future can find it quickly and that it gets removed from the unanswered list.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2024 01:30 PM
DVP,
I know I am uber late to this party, but you deserve some props. This is exactly what I was looking for!
TY,
Ken