- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2023 02:20 PM
how can I enable the notification field for all users, in the sys_users? I have over 7000 users and I don't want to do it one by one, currently, it is set to disable.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2023 03:00 PM - edited ‎03-20-2023 05:18 PM
Hi,
Try the following:
// Enable notification for users where it is disabled
var dryRun = true;
var suRecord = new GlideRecord('sys_user');
suRecord.addEncodedQuery('notification=1');
suRecord.query();
gs.info("EnableUserNotification: Updating " + suRecord.getRowCount() + " records.");
while (suRecord.next()) {
gs.info("EnableUserNotification: Updating user: " + suRecord.name);
suRecord.notification = 2;
if (!dryRun)
suRecord.update();
}
set 'dryRun' to false after testing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2023 03:00 PM - edited ‎03-20-2023 05:18 PM
Hi,
Try the following:
// Enable notification for users where it is disabled
var dryRun = true;
var suRecord = new GlideRecord('sys_user');
suRecord.addEncodedQuery('notification=1');
suRecord.query();
gs.info("EnableUserNotification: Updating " + suRecord.getRowCount() + " records.");
while (suRecord.next()) {
gs.info("EnableUserNotification: Updating user: " + suRecord.name);
suRecord.notification = 2;
if (!dryRun)
suRecord.update();
}
set 'dryRun' to false after testing.