Hi There
I am trying to update 42000 project tasks using a map reduce.
I can't seem to find much online of how to modify the get input stage so that it processes more than 4000 search results.
So far, I have the following script
/** * @NApiVersion 2.x * @NScriptType MapReduceScript */define(["N/search", "N/record", "N/log", "N/runtime"], function ( search, record, log, runtime) { function getInputData() { var scriptObj = runtime.getCurrentScript(); // var projectName = scriptObj.getParameter({ // name: "custscript_project_name", // });
var projecttaskSearchObj = search.create({ type: "projecttask", filters: [["custevent_prj_tsk_exp_category", "anyof", "@NONE@"]],
columns: [ search.createColumn({ name: "id", label: "ID" }), search.createColumn({ name: "title", label: "Name" }), search.createColumn({ name: "company", label: "Project" }), search.createColumn({ name: "custevent_prj_task_item", label: "Item", }), search.createColumn({ name: "custevent__prj_tsk_exp_category", label: "Expense Claim Category", }), ], }); var searchObjPagedData = projecttaskSearchObj.runPaged({ pageSize: 1000, });
var resultCount = 0; var results = [];
searchObjPagedData.pageRanges.forEach(function (pageRange) { if (resultCount >= 4000) { return false; // Break out of the loop if we've already processed 4000 results }
var page = searchObjPagedData.fetch({ index: pageRange.index, });
page.data.forEach(function (result) { if (resultCount < 4000) { results.push(result); resultCount++; } }); });
return results; }
How do I adjust this so that the script processes more than 4000 search results?
Looking at the execution log, it states that the script yielded 2 times even though it only ran for 30 mins. Why would it yield more than once?
Thanks