Anyone know how to set the HTML template manually ...
# suitescript
u
Anyone know how to set the HTML template manually for render.statement using SS2 to use
Advanced PDF/HTML Templates
? The default template it's using is terrible and can't be customized much since it's the template located in
Custom PDF Layouts
. I've tried setting the property
options.formId
to the internal ID of an Adv PDF/HTML, with both the record ID and the string ID (pointlessly since the property takes in a number), to no avail. Am I all out of options and just forced to run a saved search and compile a statement manually instead? Any and all inputs appreciated, thanks.
e
IIRC you set the
formid
to the id of a custom form that has the advanced template set.
u
I've tried doing this (as mentioned), to no avail. Is there a specific way of doing this or am I just unaware of a setting that isn't enabled? Advanced Templates are enabled on our domain so I don't think that's the issue.
n
I don't have the full suite I created at the time but this snippet may help:
Copy code
var theRender = render.create();
theRender.setTemplateById(myTemplateId);
theRender.addRecord({
   templateName: 'record',
   record: record.load({
      type: record.Type.ITEM_RECEIPT,
      id: myRecordId
   })
});
theRender.addRecord({
			templateName: 'porecord',
			record: record.load({
				type: record.Type.PURCHASE_ORDER,
				id: myParentId
			})
		});
		theFinalPDF = theRender.renderAsPdf();
Note the second line, is that how you're assigning the template?
u
@NElliott I'm assigning it using `render.statement()'`s
formId
property. Here's code snippet I'm using currently:
Copy code
var statement = render.statement({
          entityId: customerField,
          printMode: render.PrintMode.HTML,
//        formId: neither "custtmpl_statement" nor 109 works,
          startDate: startField,
          statementDate: statementField,
          openTransactionsOnly: openField,
          consolidateStatements: consolidateField
});
Hence my dilemma as this function seems to only want to use the
Custom PDF Layouts
or
Custom HTML Layouts
templates.
n
I've not used that particular renderer function. Maybe try creating that statement object without the formId property set, JSON.stringify it and see what properties it has, maybe the docs are wrong and it's not formId. Alternatively create the object then set statement.formId afterwards. I know you're probably thinking it sounds madness but honestly with NS and this module and their documentation...
u
that's understandable. I'll get back here after I give it a try first. My only real reason for using this specific function is because I'm trying to generate a statement and plan to attach it to an email (which gets sent after this is generated), as it's the only documented function that generates statements. Thanks.
👍 1
e
You mentioned you used the id of the template, not the id of the custom form
u
@ehcanadian I have tried using both types of IDs for the same
Advanced PDF/HTML Template
. While they usually have their string ID displayed in the list when you open the templates' page, they also have an internal ID in the url, which I've also tried attaching in the property, but to no avail still. I'm led to the conclusion that
render.statement()
itself is hard-coded to only use the old template formats (
Custom PDF/HTML Layouts
), without much options to utilize the newer ones. As of now my current solution is to just create a template using the Adv Template editor, export it as XML and manually assign it via SS2, seeing as there seems to be no other way to make this work. Thanks for the inputs, and sorry for the late reply.
e
Have you used the id of the statement form, not the template? The template is loaded via the form.
u
I'm not quite sure what you mean by the statement form. As I'm aware, there's no such thing as a "Statement Record Type", although we do have a SuiteBundle for a "Statement Form", yet there is no existing record for it, nor can I make a new record for it. Unless I'm misunderstanding something, I'm quite sure there's no such thing as "id of the statement form", as all statements we've generated thus far have been based on Sales Invoices, and applied on a terrible template. Maybe you can elaborate?
e
Every record type has an associated form with it. You're able to customise the form, (Customization -> Forms -> Transaction forms.) You set the advanced PDF template when customising the form and the id you use or rendering is the id of the custom transaction form, not the template.