Hey all! I’m attempting to create a button that ca...
# suitescript
f
Hey all! I’m attempting to create a button that calls a Suitelet to render a pdf based on a saved search and an existing advanced pdf. When I run log.debug on my search result, it looks fine. But the problem has been how to render everything into an pdf. Here’s how I do my search:
Copy code
const searchInternalDeliveryNote = search.load({
        id: 'customsearch5102',
        type: search.Type.ITEM_RECEIPT
    })

    searchInternalDeliveryNote.filters.push(search.createFilter({
        name: 'internalid',
        operator: search.Operator.ANYOF,
        values: id
    }))

    const rs = searchInternalDeliveryNote.run()

    const resultsInternalDeliveryNote = rs.getRange({ start: 0, end: 1000 })
Here’s how the rendering looks (which I’m struggling with; gives an empty page)
Copy code
renderer.setTemplateByScriptId({ scriptId: 'CUSTTMPL_125_5339149_SB1_982' }) 

renderer.addSearchResults({
    templateName: 'CUSTTMPL_125_5339149_SB1_982',
    searchResult: resultsInternalDeliveryNote
})

context.response.setHeader({
        name: 'content-disposition',
        value: 'inline; filename="' + pdfFileName + '_' + custom_id + '.pdf"'
    })

context.response.writeFile({ file: renderer.renderAsPdf(), isInline: true })
b
a little on the unusual side, usually you make the template work in the ui first
in which case the data wouldnt be in the resultsInternalDeliveryNote key
id recommend getting the template working on search results from the ui first
or at least sharing the template