Ask Your Question
4

How to use Netsuite's custom print button with an HTML template?

asked 2023-07-05 14:36:43 +0000

bukephalos gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-07-05 14:37:02 +0000

lalupa gravatar image

To use NetSuite's custom print button with an HTML template, follow these steps:

  1. Create an HTML template in NetSuite using the SuiteScript 2.0 HTML module or create an external HTML file and upload it to NetSuite's File Cabinet.

  2. On the record you wish to print, create a custom button and set the following properties:

  • Label: Print
  • ID: CustomPrintButton
  • Script: Leave blank
  • Function Definition: window.open('/app/site/hosting/scriptlet.nl?script=XX&deploy=YY&print=T', '_blank');

Replace XX and YY with the script ID and deployment ID of the Suitelet you will create in the next step.

  1. Create a Suitelet with the following code:

function onRequest(context) { var recordId = context.request.parameters.id; var recordType = context.request.parameters.type; var printFlag = context.request.parameters.print;

if (printFlag == "T") { var renderer = nlapiCreateTemplateRenderer(); renderer.setTemplate('<nlobjtemplate templateid="123">'); renderer.addRecord(recordType, recordId); var result = renderer.renderToString();

  context.response.writePage(result);

} else { // Return the Suitelet form here } }

Replace '123' with the ID of the HTML template you created in step 1.

  1. Deploy the Suitelet and note the deployment ID.

  2. Update the CustomPrintButton button's Function Definition with the correct script ID and deployment ID from step 4.

  3. Save the custom button and test it by opening the record and clicking the Print button. It should open a new tab with the HTML template populated with the record data.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-07-05 14:36:43 +0000

Seen: 9 times

Last updated: Jul 05 '23