Reputation: 11
I need to do a search of more than 6000 elements, and generate a PDF with their information, everything works fine when there are few elements, but with large quantities I have this problem, I am a newbie in this, I am not sure if the time can be increased runtime or the search result can be divided in some way,, thanks in advance, here is my code:
var objSearch = search.load({
id: 'customsearcht_itemid_lp'
});
var paginado = objSearch.runPaged({
pageSize: 1000,
});
paginado.pageRanges.forEach(function (pageRange) {
var myPage = paginado.fetch({index: pageRange.index});
myPage.data.forEach(function (result) {
var iditem = result.getValue({name: 'internalid'});
var bprice = result.getValue({name: 'baseprice'});
var dname = result.getValue({name: 'displayname'});
var vinopuntos = Math.round(parseFloat(Buquedadeporcentaje(iditem,Ubicacion)) * parseFloat(bprice));
if (!vinopuntos){vinopuntos=0;}
log.audit({title: 'vino', details: vinopuntos});
result.datositem = {
iditem: iditem,
basep: bprice,
dname: dname,
vinopuntos: vinopuntos }
arraypag.push(result.datositem);
});
log.audit({title: 'Número de página', details: arraypag});
});
var renderData = {
cantidad: arraypag.length,
articulos: arraypag
};
var renderPdf = render.create();
renderPdf.setTemplateById(268);
renderPdf.addCustomDataSource({
format: render.DataSource.OBJECT,
alias: "ETIQUETAS",
data: renderData
});
var transactionFile = renderPdf.renderAsPdf();
context.response.writeFile({
file: transactionFile,
isInline: true
});
Upvotes: 1
Views: 4453
Reputation: 111
Just for reference: the Time Limit for the SuiteLet script is 5 minutes, please see https://netsuite.custhelp.com/app/answers/detail/a_id/45311 suite answer for the details on script time limits. First, we need to identify what exactly causes the time limit hit. It is either running the search or generating the PDF. Can you please add the log message after the search code block and run your scripts for 6000 records. If you do not see that log message (please see the Execution log of the script) the problem is in search. So maybe the Saved Search that you use have some complex joins or returns the data that you do not really need in your script. In this case, I would recommend just set up your search in the code using N/Search module and put only those columns you really need. Please, let me know if it helps.
Upvotes: 2