My company was getting requests for credit references for some of our customers. This was a time-consuming process to format our customized response. As our NetSuite developer, I was asked to automate a custom PDF that would get emailed back to the requestor. Our staff wanted it to be easily launched from a button on the customer’s record.
I wanted to use an Advanced PDF/HTML Template to create the PDF. NetSuite supports the using advanced templates on saved search results, but there is no mechanism for launching this via a button on a customer record. And in order to get the result for just one customer, it’s another multi-step process which involved opening the Saved Search, filtering and then printing. Not acceptable!
Here are the steps I followed to build a PDFed credit reference launched from a button on a customer’s record.
1. Create a Saved Search that lets you filter to show results for just one customer.
1b. Limit your results to just one and don’t allow drill down.
2. After saving this search, click the “New Template” button at the top of the page. This step is well documented in the NetSuite documentation. Be sure you code your template so that you are processing summary results. You’ll see what I mean if you read SuiteAnswers Answer ID # 63077. <#list results as result> is where you get your summary results.
3. Since the Saved Search returns only one customer, you can code your advanced template to access fields like this.
4. It’s easy to add buttons when editing a customer. However, not so easy when you’re viewing the customer. Here’s how I did that.
In order to get the URL of my Advanced PDF/HTML Template, I had to run my query and then select a customer and print the results.
This exposed my template’s URL. I had to remove the hard-coded Internal ID of the customer and replace it. The event script passes it to the client script, which adds it to the URL as a query string parameter.
Here how this looked when it was all done. First, the new button.
And then the PDF that opens in its own window when you click the button.
I hope this saves you some time. If nothing else, it will save me some time the next I need to do something like this.