- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2022 08:40 PM - edited 11-20-2022 08:44 PM
when a user is inactive, user should be removed from the report shared by the user
Please suggest any BR and Scheduled Job
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2022 09:33 PM
Hello @Sadashiva Das1 ,
Please use this script it will give you the required results
var report = new GlideRecord('sys_report_users_groups');
report.addEncodedQuery('user_id.active=false');
report.query();
while(report.next()){
report.user_id=''
report.update()
}
Please mark my answer as correct if it helps.
BR,
Nayan
Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2022 09:39 PM
Hi @Sadashiva Das1 ,
You can writedown below BR on sys_user table
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var reportShare = new GlideRecord("sys_report_users_groups");
reportShare.addQuery("user_id", current.sys_id);
reportShare.query();
if (reportShare.next()) {
reportShare.deleteMultiple();
}
})(current, previous);
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2022 09:03 PM
Hi Sadashiva,
It is recommended to control user access to reports via Roles and for scheduled reports via Groups.
For removal of 'inactive' user(s) from Group(s), use a scheduled job or BR to remove group membership.
Thanks, Saptarshi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2022 09:06 PM - edited 11-20-2022 09:07 PM
Some reports are shared individually to many users . need to remove one of those .
Please suggest ,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2022 09:33 PM
Hello @Sadashiva Das1 ,
Please use this script it will give you the required results
var report = new GlideRecord('sys_report_users_groups');
report.addEncodedQuery('user_id.active=false');
report.query();
while(report.next()){
report.user_id=''
report.update()
}
Please mark my answer as correct if it helps.
BR,
Nayan
Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2022 09:39 PM
Hi @Sadashiva Das1 ,
You can writedown below BR on sys_user table
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var reportShare = new GlideRecord("sys_report_users_groups");
reportShare.addQuery("user_id", current.sys_id);
reportShare.query();
if (reportShare.next()) {
reportShare.deleteMultiple();
}
})(current, previous);