Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
**Enhancement**
1. This code will create the sp favorites of the selected users along with the sys_ui_bookmarks.
2. The entry will be made in "sp_favorite" through new **createPortalFav** function.

You can use this script to take an existing favaourite from the sys_ui_bookmark table and create a copy of it for any number of users.
Can be useful when onboarding new staff, doing testing, etc.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
var srcFav = ""; // Add the sys_id of the favourite to copy, from sys_ui_bookmark table
var portalFav = ""; // Add the sys_id of the favourite to copy, from sp_favorite table.
var userCriteria = ""; // Add an encoded query of users from sys_user table

var fav = new GlideRecord("sys_ui_bookmark");
fav.get(srcFav);

var portalFavRec = new GlideRecord("sp_favorite");
portalFavRec.get(portalFav); // glide record of favorite record.

var users = new GlideRecord("sys_user");
users.addEncodedQuery(userCriteria);
users.query();
Expand All @@ -18,4 +21,18 @@ while(users.next()) {
newFav.setValue("url",fav.url);
newFav.setValue("user",users.sys_id);
newFav.insert();

createPortalFav(users); // function to create portal favorites
}
function createPortalFav(userRec){
var newPortalFav = new GlideRecord("sp_favorite");
newPortalFav.initialize();
newPortalFav.setValue('user',userRec.user);
newPortalFav.setValue('reference_table',portalFavRec.reference_table);
newPortalFav.setValue('reference_document',portalFavRec.reference_document);
newPortalFav.setWorkflow(false); // OOB Sscript include take the logged-in user to check the duplicate records so workflow false restricts the SI to run.
newPortalFav.insert();
}



Loading