The CreatorCon Call for Content is officially open! Get started here.

Duplicate dashboard

Vedanti_
Tera Contributor

Hi all,

 

I'm trying to duplicate a dashboard but the new dashboard is still using reports from original dashboard. Is there a way by which we can duplicate a dashboard with duplicate reports. I thought of duplicating reports and creating a new dashboard all together but It is too much of manual steps.

 

Please feel free to share your thoughts

 

Thanks in advance 🙂

5 REPLIES 5

Marco0o1
Tera Sage

Hi @Vedanti_ :

 

You can try something like this, I just created and you can give a try running a background script

 

var dashboard_sys_id = "sys_id of duplicated dashboard"; //sys_id of the duplicated dashboard [new];

var mapping = {
    "61127d25770230107384c087cc5a99ad": "5942f165770230107384c087cc5a9963",
    "5942f165770230107384c087cc5a9963": "61127d25770230107384c087cc5a99ad2"
}; //Here mapp the existing sys_id of the report and on the right side the new sys_id of your dashboard that you want to replace. You can write as much as you want


var dashboardTabsGR = new GlideRecord("pa_m2m_dashboard_tabs");
dashboardTabsGR.addQuery("dashboard", dashboard_sys_id);
dashboardTabsGR.query();

while (dashboardTabsGR.next()) {
    var tabGR = new GlideRecord("pa_tabs");
    tabGR.get(dashboardTabsGR.tab);

    var pageGR = new GlideRecord("sys_portal_page");
    pageGR.get(tabGR.page);

    var portalGR = new GlideRecord("sys_portal");
    portalGR.addQuery("page", pagrGR.sys_id);
    portalGR.query();

    while (portalGR.next()) {
        var portalPreferencesGR = new GlideRecord("sys_portal_preferences");
        portalPreferencesGR.addQuery("portal_section", portalGR.sys_id);
        portalPreferencesGR.addQuery("name", "sys_id");

        while (portalPreferencesGR.next()) {
            if (mapping[portalPreferencesGR.value]) {
                portalPreferencesGR.value = mapping[portalPreferencesGR.value];
                portalPreferencesGR.update();
            }

        }

    }

}

 

If I am correct it will replace the existing report with a sys_id of a new one that you want to replace in the dashboard with the same values.

 

 

Regards,

 

Marco