This is the code im using, Im attaching some data ...
# suitescript
i
This is the code im using, Im attaching some data using
addCustomDataSource
, but for testing purposes I commented that out and just left the code as below an still didnt work, I still get an unexpected error
Copy code
let renderer = render.create();

renderer.setTemplateByScriptId({
  scriptId: setupData.ciPDFTemplate,
});


const pdf = renderer.renderAsPdf();
b
you probably want to put back the data source
and make sure its valid
i
nope, I added this
Copy code
renderer.addRecord({
    templateName: 'header',
    record: record.load({
        type: 'customrecord_bit_ci_header,
        id: 1234
        });
    });
Just before the
setTemplateByScriptId
and still got unexpected error 😤 And is a valid data source, I tested it on the suitelet with the same data and it worked
b
what did the suitelet code look like
i
Exactly the same, I just copied and pasted the function because I thought it would be faster than handle authentication and all that from calling the suitelet from the MR haha
renderer = render.create() -> renderer.addRecord() -> renderer.setTemplateByScriptId() -> renderer.renderAsPdf();
b
i wouldnt expect suitelet code to act differently than map/reduce code unless specific restrictions were added on the custom record or its fields
i
Dont know if this affects it but Im doing this on the MAP stage
b
beyond permission related issues
i would make extra sure that the code is identical
i
Oks, gonna double check the code and check also the permissions
Thanks!
b
that usually means hardcoding your ids so that it literally is copy and paste
i
ok, so I changed the id from the template from this
CUSTTMPL_CI_PDF
to this
custtmpl_ci_pdf
and now Im getting a
MISSING_PDF_PARAMETERS
error 😐
b
what does the pdf template look like?
i
Thats a bit complicated, is a really ugly xml haha, do you think that the issue is on the template itself? But Ill check that later I need to sleep, thanks for the help! Ill keep you updated if I manage to make this work
b
you may want to render it as a string
so that you can compare its output to the suitelet