We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Copying bookmarks to another user's profile

alliej428
Kilo Contributor

Hi-

Is there a way to copy over bookmarks from one user's profile to another?   I've looked but haven't found a way to do so, and I'm not sure if this is possible.

Thanks!

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

Option 1: Copy them manually by going to sys_ui_bookmark.list, filter for the user and bookmarks you want, open each, replace the user name, right click the form header and select "Insert".



Option 2: Write a script to filter and copy them. This is a bit more involved and a knowledge of JavaScript and the GlideRecord API.



GlideRecord - ServiceNow Wiki


View solution in original post

15 REPLIES 15

lginq
Tera Contributor

This is the simple script I like to use

var targetUserId = ''; 
var sourceUserId = ''; 

var groupMap = {};

copyGroups(sourceUserId, targetUserId)
copyFavourites(sourceUserId, targetUserId);

function copyGroups(source, target) {
    var gr = new GlideRecord('sys_ui_bookmark_group');
    gr.addQuery('user', source);
    gr.query();
    while (gr.next()) {
        gr.setValue('user', target);
        groupMap[gr.getUniqueValue()] = gr.insert();
    }
}


function copyFavourites(sourceUserID, targetUserID) {
    var gr = new GlideRecord('sys_ui_bookmark');
    gr.addQuery('user', sourceUserID);
    gr.query();

    while (gr.next()) {
        gr.setValue('user', targetUserID);
        gr.setValue('group', groupMap[gr.getValue('group')]);
        gr.insert();
    }
}