The scheduled or map/reduce script only used as a dependent script.
Here we used the saved search to convert the search result as a csv file and stored in the file cabinet.
// Specify a file for the search results
let asyncSearchResultItemFile = ‘file path need to give here’;
// Create a map/reduce script task
let itemMapReduceScript = task.create({
taskType: task.TaskType.MAP_REDUCE
});
itemMapReduceScript.scriptId = ‘script id’;
itemMapReduceScript.deploymentId = ‘deployment id’;
//Create a task for the dependent script
let itemSearchTask = task.create({
taskType: task.TaskType.SEARCH
});
itemSearchTask.savedSearchId = internal id of the search;
itemSearchTask.filePath = asyncSearchResultItemFile;
itemSearchTask.addInboundDependency(itemMapReduceScript);
//Submit the process
let searchItemTaskId = itemSearchTask.submit();