Sunday, October 21, 2018

Sample Code to Generate a PDF File Using nlapiXMLtoPDF

Image
Duration: 6 minutes


The following set of instructions shows how to create a PDF file that can be called with a click of a button. A button is first added to a form. Clicking the button retrieves the necessary data from the current record and creates a PDF file. The created PDF file will then be shown by using a Suitelet.

1. Create a Suitelet with the following code. This will create the PDF file using nlapiXMLToPDF in conjunction with Big Faceless Organization (BFO). Note that the internal id of the current record that is passed as a parameter will be used to load the record.   


Suitelet Script Deployment:

 2. Create a Client script that will call the Suitelet. In this script, the internal id of the current record is being passed to the Suitelet.  Note the deployment settings of this script wherein no function is specified. This is because the function will only be called by the User Event script on Click of the custom button.  
 
 
Client Script Deployment:

 
3. Create a User Event script that will add a custom Button on a form. This will be triggered on Before Load function. Note that the function name of the Client script is specified. The Client script is then set using "setScript".  
 
 


User Event Script Deployment:

This sample shows a custom button on the Purchase Order record labeled as "Print  Item Barcode".
 
On load of the Purchase Order record, the button "Print  Item Barcode" is immediately displayed. Clicking this button will generate the PDF file which contains all the Items contained under the Items tab > Items subtab. The PDF file will display 5 columns which are Item, Rate, Barcode, Quantity and Amount.
 
1. View a Purchase Order
2. Click the button "Print  Item Barcode"
3. A window opens containing the PDF file that was generated. It contains the data from Items on the Purchase Order record 

No comments:

Post a Comment