5
Points
Questions
0
Answers
2
-
The error is pointing at the wrong line —
renderAsPdf()is where it surfaces, but the template was already lost three lines earlier. Three fixes:First,
setTemplateByScriptIdreturns void. This line loads your template and then immediately overwrites it withundefined:renderer.templateContent = renderer.setTemplateByScriptId("custtmpl_nscs_bin_label");Don’t assign it — just call it.
Second, the next line renders the template before any search results are bound, then stuffs that output back in as the new template. Delete it entirely — you only render once, at the end, after the data is added.
Third, the sneaky one:
setTemplateByScriptIdrequires the script ID in UPPERCASE. Passcusttmpl_...lowercase and it fails silently — no error at that line — and the failure only shows up later atrenderAsPdf()as MISSING_PDF_PARAMETERS.Working version of that section:
var renderer = render.create(); renderer.setTemplateByScriptId("CUSTTMPL_NSCS_BIN_LABEL"); renderer.addSearchResults({ templateName: 'results', searchResult: searchResult }); var newfile = renderer.renderAsPdf();Your template’s fine —
<#list results as result>matchestemplateName: 'results', so once the renderer actually has the template and the data in that order, it should produce your bin labels.One structural note: a 2.x scheduled script should use
define()returning an{execute: ...}entry point rather thanrequire()with an immediately-invoked function — worth fixing while you’re in there.The “silent failure upstream, error downstream” pattern here is common enough with this API that I wrote it up: https://nesystemsgroup.com/tips/missing-pdf-parameters-settemplatebyscriptid
- 1559 views
- 2 answers
- 0 votes
-
“nothing else is queued” is almost always one of two invisible things: work you can’t see, or fewer processors than you think.
On the first: scheduled scripts and map/reduce scripts share the same SuiteCloud processor pool, but they display on two different status pages (Scheduled Script Status vs Map/Reduce Script Status), and both pages default to filters — date, owner, deployment. A scheduled script from a bundle or another admin can be holding a processor while your filtered view looks empty. Clear every filter on both pages before trusting them, or install Oracle’s free APM SuiteApp — its SuiteCloud Processors Monitor shows actual processor utilization, which ends the guessing.
On the second: the pool is smaller than most people realize. A base account gets 2 processors total for all scheduled + map/reduce work combined. Each SuiteCloud Plus license adds 5. And a single map/reduce script can occupy multiple processors by itself — the Concurrency Limit on its deployment is how many it grabs for the map/reduce stages. So one MR with concurrency 2 on a base account = the entire pool is occupied, and everything else sits in Pending while both status pages look quiet.
“Deferred” specifically is the priority system at work — deployments have a Priority field, and Standard/Low priority submissions get deferred when the pool is contended. And even on a truly idle account there’s normal dispatch latency: the framework picks up queued work on an interval, so 30–60 seconds of Pending means nothing.
So two questions that will probably solve it: how many SuiteCloud Plus licenses does the account have, and what’s the Concurrency Limit on your map/reduce deployments? If the answers are “none” and “2,” there’s your invisible queue — the script is occupying it all by itself.
The broader point is that Pending/Deferred (and MAP_REDUCE_ALREADY_RUNNING when you submit programmatically) describe the state of the processor pool, not a failure of your request — treating them as errors is how people end up resubmitting and duplicating work. I wrote up that pattern here: https://nesystemsgroup.com/tips/map-reduce-already-running-is-a-queue
- 3385 views
- 2 answers
- 0 votes