Hey all, we currently use an advanced pdf/html tem...
# advancedpdf
m
Hey all, we currently use an advanced pdf/html template packing slip that pulls item data from both the fulfillment and the sales order. I’ve created a button using suitescript to print using the same template but through the script it seems that I don’t have any access to the sales order sublist. any suggestions? what am I missing? TIA
d
presume you're using
N/render
. Are you using
render.transaction
or
render.packingSlip
? I haven't tested, but presume the latter would solve your issue. Would be interested to know if that's the case, please let me know
m
Thanks @David B here is my code
Copy code
if (recordId) {
          const fulfillmentRecord = nRecord.load({
            type: nRecord.Type.ITEM_FULFILLMENT,
            id: recordId
          });
          const ftlTmplFile = nFile.load('Templates/PDF Templates/NEW-Commercial Invoice Packing Slip.ftl');
          const renderer = nRender.create();

          renderer.templateContent = ftlTmplFile.getContents(); 
          renderer.addRecord('record', fulfillmentRecord);
  
          const pdfFile = renderer.renderAsPdf();
  
          context.response.writeFile({
            file: pdfFile,
            isInline: true
          });
        }
d
yeah, give render.packingSlip() a go
👍 1
m
I will look into your suggestion.
d
if that doesn't work, just load and add the sales order to the templateRenderer the same as you're doing for the item fulfillment Though my intuition is that render.packingSlip will be faster
m
Thanks for the help. I’ll test tomorrow and update you on the result
👍 1
d
aha, the direct `Render.transaction`/`packingSlip` take a
formId
instead of a template directly. So you'd have to have a form (could be the default form) that had your packing slip template on it. As opposed to using the
Render.TemplateRenderer
, where you can specify the
templateContent
property directly from a ftl template file's contents (as you are currently doing).
m
That makes sense. Thanks again. HUGE help