push favorites to multiple users

tkrishna29
Giga Guru

Hi,

This requirement may look dumb. But just curious.

My business lead wants some favorites to be pushed across to multiple users. Is that even possible?

I remember this can be done for Mobile UI but not for desktop interface.

Last thing I can say to her is train her users to create favorites by themselves or ask my team to manually create the same kind of favorites to all those users (around 20) by impersonating as those users.

Appreciate your advise.

Thanks,

Krishna

7 REPLIES 7

Ok, thanks for the feedback. Have a nice day.


Peter de Bock1
Mega Guru

Hi Krishna,

I have created a Fix Script which copies and/or updates Bookmarks from an User to a set of Users. Although it needs to be run by an admin, it could possibly be interesting for you.

I attached the Fix Script.

If you like it 🙂  please mark my response as helpful

regards, Peter

 

// Cloning Favorites (Bookmarks) of an User
// Note: Existing bookmarks will be updated based upon the Bookmark title

// Input
var UserFrom= "df2acc0fdb10470056d57e400f96191d"; // Set the sys_id of the User to clone the Bookmarks from
var UsersTo= ["c997c007db10470056d57e400f961919","5f2acc0fdb10470056d57e400f96193c","0ce92383dbad0380e823bc2ffe961987"]; // Set the sys_id's of the Users to clone the Bookmarks to

var gr = new GlideRecord('sys_user');
if (gr.get(UserFrom)) {
	var grBook = new GlideRecord('sys_ui_bookmark');
	grBook.addEncodedQuery('user=df2acc0fdb10470056d57e400f96191d');
	grBook.query();
	gs.log('Start cloning bookmarks from ' + gr.name,'Cloning Favorites (Bookmarks)');
	while (grBook.next()){
		var x;
		
		for (x in UsersTo){
			
			
			//Verify upon existence. Update when already exist
			var grBookCheck = new GlideRecord('sys_ui_bookmark');
			grBookCheck.addEncodedQuery('user='+UsersTo[x]+'^title='+grBook.title);
			grBookCheck.query();
			if (grBookCheck.next()){
				
				grBookCheck.url = grBook.url;
				grBookCheck.order = grBook.order;
				grBookCheck.update();
				gs.log('Bookmark ' +grBook.title + ' updated from ' + gr.name + ' to ' + grBookCheck.user.name,'Cloning Favorites (Bookmarks)');
			} else {
				
				grBook.user = UsersTo[x];
				grBook.insert();
				gs.log('Bookmark ' +grBook.title + ' cloned from ' + gr.name + ' to ' + grBook.user.name,'Cloning Favorites (Bookmarks)');
			}
		}
	}
	gs.log('End cloning bookmarks from ' + gr.name,'Cloning Favorites (Bookmarks)');
	
	
}

Peter,

 

Your script worked perfect. Thanks for being part of the community this saved me hours of manual impersonation and creation. 

 

-Steve
SN SC