Hi! Do you know if it is possible to add a saved s...
# suitescript
a
Hi! Do you know if it is possible to add a saved search results to a Pdf template. When on Invoice I click on print it already prints some pdf, what I want to do is to customize and add some data to it, there is a template already but I can't figure out how to add a saved search results?
h
you could create a UE script using PRINT context type and deploy it to Invoice. Here's a snippet of UE:
Copy code
const beforeLoad = (scriptContext) => {
    try {
        if (scriptContext.type !== scriptContext.UserEventType.PRINT) return;
        const {newRecord, form} = scriptContext;
        const  linesField = form.addField({
            id: "custpage_custom_lines",
            label: 'Custom Lines',
            type: ui.FieldType.INLINEHTML,
        })

        const searchResults = // create a function to get search results
        linesField.defaultValue = JSON.stringify(searchResults)


    } catch (error) {
        log.error('ERROR in beforeLoad', error.toString());
    }
}
You could get the custom lines in the pdf as follows:
<#assign data = record.custpage_custom_lines?eval>
<#list data as line>//doSomething</#list>
You might only be able to use this in the body of the pdf template. If you need to use this in head then I think you could inject a Suitelet in the head then use it
🙌 1