Has anyone had any success using SS2.0's render mo...
# suitescript
t
Has anyone had any success using SS2.0's render module to render a PDF on a button click in a UE? I'm trying to print a custom Advanced PDF that is based on a Saved Search, but the code that I'm using is throwing an unexpected error and I'm not sure what I'm doing wrong. Here is the code I'm using: const renderer = render.create(); renderer.setTemplateByScriptId({ scriptId: 'CUSTTMPL_130_630303_337' }) const pdf = renderer.renderAsPdf();
m
Looks like you need to use
Copy code
renderer.setTemplateById({ id:'CUSTTMPL_130_630303_337' })
t
@Mozsuite When I try that, I get this error message: "Cannot convert CUSTTMPL_130_630303_337 to java.lang.Integer"
m
Ah it must require the numerical ID of the template you are trying to use
t
Yeah, seems so. I changed it to the numeric internal ID and I am getting an unexpected error again. When I log the renderer just before renderAsPdf(), it shows as null which makes me think I am not loading the template properly
j
Did you add a record to your renderer? Like
Copy code
renderer.addRecord('record', record.load({
                    type: type,
                    id: internalId
                }));
t
@jarens Is it necessary to load a record when using a template that is based off a saved search?
j
I'm not sure. I haven't really ever played with rendering pdfs off saved searches so out of my expertise.
t
Same 😞
Looks like there also an addSearchResults method same as add record