how to delete the bookmarks when the role remove to a group
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2024 12:17 PM
how to delete the bookmarks when the role remove to a group for those group members have to delete the bookmarks.
I have tried with after delete business rule on sys_group_has_role table, can any one help me on this query
the BR script:
(function executeRule(current, previous /*null when async*/ ) {
var grGroupRole = new GlideRecord('sys_group_has_role'); // Gliding the sys_group_has_role table
grGroupRole.addQuery('role.name', 'pps_resource'); // checking if group has 'pps_resource' role
grGroupRole.addQuery('group', current.sys_id);
grGroupRole.query();
if (!grGroupRole.hasNext()) { // If the group does not have 'pps_resource' role
while (grGroupRole.next()) {
var group = grGroupRole.group.getRefRecord(); // Get the group record
gs.info("hello");
var grUser = new GlideRecord('sys_user_grmember'); // Gliding the sys_user_grmember table to get the group members
grUser.addQuery('group', current.sys_id);
grUser.query();
while (grUser.next()) {
var user = grUser.user.getRefRecord(); // Get the user record
// Define the bookmarks that you want to delete
var bookmarks = [
'Projects (Active)',
'Demands (Active)',
'Pipeline and Resource Dashboard'
];
// For each bookmark
for (var i = 0; i < bookmarks.length; i++) {
var bookmark = new GlideRecord('sys_ui_bookmark'); // Gliding the bookmark table
bookmark.addQuery('user', user.sys_id);
bookmark.addQuery('title', bookmarks[i]);
bookmark.query();
while (bookmark.next()) { // If bookmark exists for the user with the title
bookmark.deleteRecord(); // Delete the bookmark record
}
}
}
}
}
})(current, previous);
thanks
Harivas
thanks
Harivas
6 REPLIES 6
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2024 03:38 AM
Hi @Harsh Vardhan Thanks for your code, but it's not working.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2024 06:25 AM
@harivas Can you add screenshot of your Business Rule and may I know how are you testing it ?