I have a dashboard that does this - as this is a common thing that we need to do when duplicating projects. There is a dropdown to select the project, and then checkboxes for the cubes to be affected.
The following hacked together script will disable the schedules of all cubes in the project named in the first line. If there is no schedule set, you will see a 404 in the console, but the script will still continue to the next cubes.
No responsibility taken for this script etc etc.
I’m sure that someone can do this a lot better, but something similar to this works for me.
To re-renable, just change ‘false’ to ‘true’
projectName = "PROJECT NAME";
ps = dundas.context.getService("ProjectService");
//loop through all the projects
ps.getAllProjects().done(function (projects)
{
//console.log(projects);
projects.forEach(function (eachProject)
{
//console.log(eachProject.name);
if (eachProject.name === projectName) //this is the one that we want
{
console.log("project is", eachProject.name, eachProject.id);
getChildren(eachProject.id); //get all the cubes
}
getChildren = function (projectId)
{
//get all the items in the project
dundas.context.getService("FileSystemService").getEntryById(projectId, dundas.filesystem.GetEntryOptions.INCLUDE_CHILDREN).done(function (f)
{
f.allChildren.forEach(function (eachFile)
{
if (eachFile.objectType.includes("Folder"))
{
//if a folder, recursively get the cubes from it
getChildren(eachFile.id);
}
else
{
if (eachFile.objectType.includes("DataCube")) //if it's a cube
{
console.log(eachFile.id, eachFile.friendlyName);
//disable the schedule
disableSchedule(eachFile.id);
}
}
}
);
}
)
}
disableSchedule = function (cube)
{
//get the schedule
dundas.context.getService("DataCubeService").getSchedule(cube).done(function (originalSchedule)
{
//switch it off
originalSchedule.isEnabled = false;
//put the modified schedule back into the cube
dundas.context.getService("DataCubeService").scheduleWarehouse(cube, originalSchedule);
}
)
}
}
)
}
)