I want to delete applications / modules from favourite list in Servicenow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2023 04:59 AM
I want to delete all the applications and modules in FAVOURITES via script [ fix script]
I am able to delete only modules , but not able to delete Application named " Incident" via script.
I need it via fix script so that everything [ Application + module ] should get deleted from "favourites".
I am able to delete all the modules via script from bookmarks table but , Currently i am not able to delete application "Incident"
pls note: I want it via script
pls help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2023 05:13 AM
HI @Sachin Gavhane ,
I trust you are doing great.
First, we need to identify the sys_id of the "Incident" Application. You can do this by searching for the Application in the sys_app table. Look for the record with the name "Incident" and note down its sys_id.
Once you have the sys_id of the "Incident" Application, you can delete the corresponding record from the bookmarks table. The bookmarks table stores the favorite modules and applications for each user.
// Step 1: Get the sys_id of the "Incident" Application
var incidentApp = new GlideRecord('sys_app');
incidentApp.addQuery('name', 'Incident');
incidentApp.query();
if (incidentApp.next()) {
var incidentAppSysId = incidentApp.sys_id.toString();
// Step 2: Delete the Application record from the bookmarks table
var bookmarks = new GlideRecord('sys_bookmark');
bookmarks.addQuery('module', incidentAppSysId);
bookmarks.query();
while (bookmarks.next()) {
bookmarks.deleteRecord();
}
gs.info('Successfully deleted the "Incident" Application from favorites.');
} else {
gs.info('Unable to find the "Incident" Application.');
}
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2023 05:17 AM
Hi @Sachin Gavhane ,
You can write a fix script like below and delete favorites
var gr = new GlideRecord('sys_ui_bookmark');
gr.addQuery('user', 'user sys_id');
gr.query();
while (gr.next()) {
gr.deleteRecord();
}
To delete irrespective of user, remove second line and run fix script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2024 11:50 AM
I think the answer OP was looking for is the sys_ui_bookmark_group table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2024 12:24 PM
Hi @Sachin Gavhane ,
As @BrendanF & @Manmohan K mentioned, you can perform below query to remove the fav applications as well as modules for a certain user by putting user conditions as below
var gr = new GlideRecord('sys_ui_bookmark');
gr.addQuery('user', 'user sys_id'); //put user sys_id for which you want to delete fav
gr.query();
gr.deleteMultiple();
var gr = new GlideRecord('sys_ui_bookmark_group');
gr.addQuery('user', 'user sys_id'); //put user sys_id for which you want to delete fav
gr.query();
gr.deleteMultiple();
Please note that if the records are multiple, its better to put setLimit() condition and if you want to do it for all users , comment down the second line.
Please mark my answer as helpful/correct if it resolves your query.
---
Nilesh Wahule