You would not see/access that template as a file, ...
# suitescript
a
You would not see/access that template as a file, you will use the internal id to with the function setTemplateById to the render object…
t
Thanks! I will give that a shot
Trying this:
Copy code
var results = search_object.run().getRange(0, 1000);
var renderer = render.create();
renderer.setTemplateById(117);
renderer.addSearchResults({
  templateName: 'custtmpl_template_name',
  searchResult: results
});
context.response.writePage(renderer.renderAsPdf());
which gives me a template error: "Error Parsing XML: The element type \"body\" must be terminated by the matching end-tag
but it works when I go to print from the search
any clues? Just wondering if I set it up correctly. Thanks for taking a look
Never mind - my mistake the search results length is 0
a
You need to use
N/xml
and escape characters.
t
can you explain? I fixed the search but still get that error, even when I don't write it out, just trying to renderAsPDF
I think I am doing something wrong by specifying the template ID and the templateName
seems like it would try to use the same template for each result and then render all the results through the same tempalte
though maybe I am mistaken
a
What are you trying to do exactly? what is your use case?
t
ah I see - templateName is what the results object is named inside of the template
not the name of the template
trying to render a sublist from a form on a suitelet using an advanced pdf template
progress - the error is gone now but the PDF is empty
it works with renderAsString however
a
This is a custom sublist from a search?
t
yes
I have the contents now just a matter of getting it into PDF form
renderAsString produces what I am looking for just in the wrong format
actually it works - just not to write it out to context
just tried saving it to file cabinet and it worked perfectly
thanks for your help
I appreciate it!
One more question if you are still here: for renderer.addSearchResults. How do I handle large result sets? I tried iterating through the result set and calling renderer.addSearchResults for each range iteration, but that doesn't seem to work.
a
Never used that before I normally do a JSON and add that JSON object to the render.
t
gotcha