Hi all, having a issue trying to create a PDF of ...
# suitescript
t
Hi all, having a issue trying to create a PDF of a custom record the code im using is
Copy code
objScriptParams.param_generate_pdf_letter = 'CUSTTMPL_181_102'
                    var renderer = render.create();
                    var myContent = renderer.addRecord({
                        template: 'fred',
                        record: record.load({
                            type: 'customrecord_sf_inv_out_email',
                            id: parseInt(customRecordID)
                        })
                    });
                    renderer.setTemplateByScriptId(objScriptParams.param_generate_pdf_letter);
                    var letterPDF = renderer.renderAsPdf();
The template now just has this is in it
Copy code
<?xml version="1.0"?><!DOCTYPE pdf PUBLIC "-//big.faceless.org//report" "report-1.1.dtd">

<pdf>
<body header="nlheader" header-height="10%" footer="nlfooter" footer-height="20pt" padding="5mm 15mm 5mm 15mm" size="A4">
 BOB
</body>
</pdf>
The error i am getting is:
Copy code
type: "error.SuiteScriptError",
   name: "UNEXPECTED_ERROR",
   message: "An unexpected SuiteScript error has occurred",
on the renderer.renderAsPdf(); line. Has anyone got any ideas
m
@Tim Pilgrim did you try testing without the
renderer.addRecord
part?
I'm not getting any errors on my end
message has been deleted
message has been deleted
t
i did test without the addrecord and it worked,
but I need the record for it work.... (when i put the real pdf template back)
m
Strange. If you can't figure it out, workaround would be read the fields in your script and as as a custom data source
t
and yeah when I run it in the debug it "works" doesn't error doesn't save the file to the file cabinet
but yeah custom data source might be the way to go
a
hi Tim, your custom template CUSTTMPL_181_102, what is it based on?
d
I also suspect that record can contain values that cannot be parsed like & or something else.
t
it was the customise of the default one for that custom record