James, I have a script that can work for you with some minor modifications to suit your specific needs. Youâll want to change it so it picks up multiple projects and looks for the No Data scripts (it currently picks up Loading and Ready).
Hope this helps,
Ken
/*
- This looks at all files in the project for scripts and prints their contents.
*/
console.log(âStart Script Finderâ);
var PROJECT_NAME = ââ;
var TO_FIND_TYPE = âDashboardâ;
var projectService = dundas.context.getService(âProjectServiceâ);
var fileSystemService = dundas.context.getService(âFileSystemServiceâ);
var dashboardService = dundas.context.getService(âDashboardServiceâ);
var fileIds = []; //we need these later during duplication to check in files as well as to locate the data connector file in the project.
var dashboardPromiseArr = [];
// Declare all the functions we use in processing and return them in a
// âthenâ chain within a function which weâll execute below in a queue.
var processPlan = function (sourceProject) {
// We need to recursively get all the files in the project
var queryFiles = function (sourceProject) {
var queryOptions = {
entryId: sourceProject.id,
queryOptions: dundas.filesystem.FileSystemQueryOptions.RECURSIVE_QUERY,
};
//console.log('queryEntries ', PROJECT_NAME);
return fileSystemService.queryEntries(queryOptions);
}
// After weâve got files for a project, we want to filter based on the type of file being a ScriptAction
var processFileEntries = function (entries) {
//console.log(âprocessFileEntriesâ, PROJECT_NAME);
var promise = $.Deferred();
entries.forEach(function (entry) {
if (entry.objectType === TO_FIND_TYPE) {
fileIds.push(entry.id);
//console.log('Found - type: â + entry.objectType + ', name: â + entry.friendlyName + ', id: â + entry.id);
}else{
//console.log('Skipping - type: â + entry.objectType + ', name: â + entry.friendlyName + â, id: â + entry.id);
}
});
//console.log(â*processFileEntries ', PROJECT_NAME);
return promise.resolve();
}
var getDashboards = function () {
//console.log(âgetDashboardsâ);
var promise = $.Deferred();
fileIds.forEach(function(entryId){
//console.log('Promising to get Dashboard :'+entryId);
var dashboardPromise = dashboardService.getDashboardById(entryId);
//dashboardPromise.done(function(dash){
dashboardPromiseArr.push(dashboardPromise);
//});
});
//debugger;
return promise.resolve();
}
var processDashboards = function (){
var promise = $.Deferred();
//console.log('processDashboards '+dashboardPromiseArr.length);
dashboardPromiseArr.forEach(function(dashPromise){
dashPromise.done(function(dashboardObj){
console.log('Dashboard : '+dashboardObj.friendlyName);
//beforeExportActions, resizeActions
dashboardObj.loadingActions.forEach(function(script){
if(script.script){
console.log(dashboardObj.friendlyName+':Loading:Script:');
console.log(''+script.script);
}
});
dashboardObj.readyActions.forEach(function(script){
if(script.script){
console.log(dashboardObj.friendlyName+':Ready:Script:');
console.log(''+script.script);
}
});
dashboardObj.adapters.forEach(function(adapter){
//
//onSelectChange etc.
if(adapter.clickActions){
//console.log('Adapter '+adapter.friendlyName+' ClickActions:');
adapter.clickActions.forEach(function(clickActionScript){
if(clickActionScript.actionType === 'Script' && clickActionScript.script){
console.log(dashboardObj.friendlyName+':'+adapter.friendlyName+':Click Action:Script('+clickActionScript.name+'):');
console.log(clickActionScript.script);
}
});
}
});
console.log('--------------------------------------------------');
// debugger;
});
});
return promise.resolve();
}
// Return a function to call later that has a chain of
// functions which must execute in sequence
return function () {
return queryFiles(sourceProject)
.then(processFileEntries)
.then(getDashboards)
.then(processDashboards)
//.then(getScriptsPerDashboard)
.done(function () {
console.log('Finished processing ');
});
}
};
/// Execution Block ///
//Go through all the projects.
projectService.getAllProjects()
.done(function (projects) {
// Declare this finder function which takes the friendly name given it, to be used in the plan loop below.
function getProjectByName(friendlyName) {
var result;
projects.some(function (project) {
if (project.friendlyName === friendlyName) {
result = project;
return true;
}
});
return result;
};
// Get the source project or bail out since we canât do any processing without it.
var sourceProject = getProjectByName(PROJECT_NAME);
if (!sourceProject || !sourceProject.id) {
return $.Deferred().reject(âUnable to find master project:â);
}
// Push processing jobs into a queue for each plan weâre going to duplicate from the source project.
// Weâre going to safely perform this kind of process synchronously as a safety measure and since
// we donât require speed as much as a reliable copying process.
var queue = [];
queue.push( processPlan( sourceProject) );
// After the function calls are queued, we actually execute them here
queue.reduce(
function (promise, fn) {
return promise.then(fn);
},
$.Deferred().resolve()
).then( function () {
console.log(âEnd Project Script Finderâ);
});
});//getallprojects.done