Cannot duplicate or copy a dashboard as a general user

WillyB
Tera Contributor

We have setup a default dashboard for users but they are not able to duplicate or copy it so they can customize it for themselves.  ServiceNow Documentation shows that you have to either be the dashboard owner or an admin to be able to duplicate a dashboard.  I was wondering if anyone came up with a solution where a user could be setup to duplicate a default dashboard?

9 REPLIES 9

lesliec123
Giga Contributor

I would like to second this question, not sure how to get more views on it.

WillyB
Tera Contributor

Since there was no solution available we went ahead and created a workaround ourselves.  We created a catalog item that allows the user to select a dashboard.  Once submitted a Business Rule is run that performs the copy process and then the Flow updates the RITM record with comments about the new board.  An email is also sent to the requestor providing a link to the new board.  

Hi @WillyB 

 

Would you be willing to share your business rule for this solution?  We have been facing this same challenge.

WillyB
Tera Contributor

Here's the Business Rule we put in place that runs when the user submits the catalog item.  Hope you find it helpful.

 

(function executeRule(current, previous /*null when async*/) {

    var dashboardName = current.variables.dashboard;
   
    //gs.log('xyz    '+dashboardName);
    gs.addErrorMessage(dashboardName);
var response = JSON.parse(SNC.ContentGeneratorUtil.duplicate(dashboardName));
gs.addInfoMessage(response.sys_id);
if (response.result == 'success') {
    var duplicate = new GlideRecord('pa_dashboards');
    duplicate.get(response.sys_id);
   
    //gs.log('xyz    '+owner);
    var link = "<a href='pa_dashboards.do?sys_id=" + duplicate.sys_id + "'>" + duplicate.getDisplayValue() + "</a>";
    duplicate.owner = current.variables.owner_of_the_dashboard;
    duplicate.name = current.variables.copied_dashboard_name;
    duplicate.update();
    gs.addInfoMessage(gs.getMessage('A new dashboard {0} has been created.', link));
} else {
    gs.addErrorMessage(gs.getMessage('Dashboard creation failed:{0}', response.error));
}
// redirect to current record.
action.setRedirectURL(current);

})(current, previous);