how to delete the bookmarks when the role remove to a group
- 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:
thanks
Harivas

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2024 03:38 PM
Not sure, in which case you would want this to run. But I have tried to refine the query. Let me know if it works.
(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();
while (grGroupRole.next()) {
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()) {
// 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', grUser.getValue('user'));
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);
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2024 06:54 AM
Hi @SanjivMeher
my req is when I remove the pps_resource role to one group on that time I want to remove the book marks for that group members, for that I have written BR on sys_group_has_role table and
when to run is after delete &
advance script is

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2024 09:46 AM
Did you try the above code i provided?
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2024 09:08 AM
Hi @harivas I am not sure why are you doing glide record on sys_group_has_role table ?
Can you try this way .
Write "After" business rule on "sys_group_has_role" table and set "Delete" checkbox as true.
Add filter condition on business rule , Role | Is | pps_resource
Screenshot :
BR Script :
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var grm = new GlideRecord('sys_user_grmember');
grm.addEncodedQuery("group=" + current.group);
grm.query();
while (grm.next()) {
bookmarkAction(grm.getValue('user'));
}
function bookmarkAction(user) {
var bookmarks = [
'Projects (Active)',
'Demands (Active)',
'Pipeline and Resource Dashboard'
];
for (var i = 0; i < bookmarks.length; i++) {
var bookmark = new GlideRecord('sys_ui_bookmark'); // Gliding the bookmark table
bookmark.addQuery('user', user);
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);
Hope it will help you.
Thanks,
Harsh