Name

global.ConvertHomePagesAjax

Description

This script gets homepages sys Ids, create associated dashboards for those that don t have yet associated dashboards, and displays a constructed info message with a link to the newly created associated dashboards. keep in mind - Homepages that have already associated dashboards will be skipped (no additional dashboards will be created and they will not be included in the constructed link) - When creating the dashboards we are migrating the permissions of the homepage also - and we store them in the dashboard permissions table

Script

var ConvertHomePagesAjax = Class.create();
ConvertHomePagesAjax.prototype = Object.extendsObject(AbstractAjaxProcessor, {

  convertHomepagesToDashboards: function() {
      var selectedSysIds = this.getParameter('sysparm_selected_homepages');
      var dashboardSysIds = new SNC.PortalPagesMigration().convertHomePagesAndgetAssociatedDashboards(selectedSysIds);
      this._displayMessage(dashboardSysIds);
  },

  _displayMessage: function(dashboardSysIds) {
      var msg;
      var length = dashboardSysIds.split(',').length;
      if (length > 0) {
          var tinyUrl = new GlideTinyURL().createTinyURL("pa_dashboards_list.do?sysparm_query=sys_idIN" + dashboardSysIds);
          msg = gs.getMessage('{0} dashboards have been created successfully. Permissions of the homepages were migrated to the new dashboards and stored in the dashboard permissions table. View the results <a href="{1}">here</a>.', [length + '', tinyUrl]);
      } else
          msg = gs.getMessage('No new dashboards were created.');

      gs.addInfoMessage(msg);
  },

  type: 'ConvertHomePagesAjax'
});

Sys ID

d6bf506bc3413010cfdbe0dd9740ddff

Offical Documentation

Official Docs: