nlapiPrintRecord(type, id, mode, properties)
Returns an nlobjFile object containing the PDF or HTML document. This API is supported in user event, scheduled, and Suitelet scripts.
There are two primary use cases for nlapiPrintRecord:
1. Send email or fax attachments using either nlapiSendEmail(author, recipient, subject, body, cc, bcc, records, attachments) or nlapiSendFax(author, recipient, subject, body, records, attachments).
For example, can be created a PDF or HTML object of a transaction or statement and then send the object as an attachment. This would be useful when sending out monthly collections notices for customers with overdue invoices.
2. Stream PDF/HTML documents to the server (for example, to maintain an archive of statement/transactions on your server).
Important: nlapiPrintRecord is not supported in client scripting. This is a server-side-only API. Also note that this function does not send transactions or statements to a printer to be printed. It also does not launch Adobe Acrobat if the mode specified is PDF.
Parameters
* type {string} [required] - Print operation type. Can be any of the following:
- TRANSACTION
- STATEMENT
- PACKINGSLIP
- PICKINGTICKET
- BILLOFMATERIAL
* id {int} [required] - The internal ID of the record being printed
* mode {string} [optional] - The output type: PDF|HTML|DEFAULT. DEFAULT uses the user/company preference for print output
* properties {hashtable} [optional] - Name/value pairs used to configure the print operation.
- TRANSACTION: formnumber
- STATEMENT: openonly (T|F), startdate, statementdate, formnumber
- PACKINGSLIP: formnumber, itemfulfillment
- PICKINGTICKET: formnumber, shipgroup, location
Example 1
This example shows that a PDF object is created form a specific transaction. The object is then saved as a file using nlapiSubmitFile. Note that by using of TRANSACTION as the type parameter, the internal Id of the transaction record should be used. (e.g Item Fulfillment, Sales Order, Purchase Order…). Using this API is the equivalent of clicking the Print button in UI.
var file = nlapiPrintRecord('TRANSACTION', 1474, 'PDF', null); //internal id of transaction (e.g Item Fulfillment)
file.setFolder(5);
nlapiSubmitFile(file);
var x = 1;
Example 2
In this example, a Customer Statement is printed in PDF that will be saved as a file. Note that by using of STATEMENT as the type parameter, the internal Id of the customer record should be used. This is equivalent to printing Statements from Transactions > Managements > Print Checks and Forms.
var file = nlapiPrintRecord('STATEMENT', 12, 'PDF', null); //internal id of customer
file.setFolder(5);
nlapiSubmitFile(file);
var x = 1;
Example 3
The example below shows that a PDF object is created from a specific transaction for Packing Slip. This is the same as printing forms when navigate to Transactions > Management > Print Checks and Forms > Packing Slips and Return Forms.
var file = nlapiPrintRecord('PACKINGSLIP', 741, 'PDF', null); //internal id of transaction (e.g Sales Order)
file.setFolder(5);
nlapiSubmitFile(file);
var x = 1;
Example 4
In the following example, a Picking Ticket is printed in a PDF file. This is the same as going to Transactions > Management > Print Checks and Forms > Picking Tickets.
var file = nlapiPrintRecord('PICKINGTICKET', 4187, 'PDF', null); //internal id of transaction (eg. Sales Order)
file.setFolder(5);
nlapiSubmitFile(file);
var x = 1;
Example 5
This example shows that a PDF object is created from a specific Work Order. Note that by using of BILLOFMATERIAL as the type parameter, the internal Id of the Work Order record should be used. Using this API is the same as going to Transactions > Manufacturing > Enter Work Orders > List > View a Work Order > click Print BOM.
var file = nlapiPrintRecord('BILLOFMATERIAL', 4291, 'PDF', null); //internal id of Work Order
file.setFolder(5);
nlapiSubmitFile(file);
var x = 1;
for a type PACKINGSLIP is there a way to customize the PDF file name to show the Item Fulfillment number?
ReplyDeleteFor type PACKINGSLIP how do I customize the PDF file name to include the Item Fulfillment number?
ReplyDeleteThank you because you have been willing to share information with us. we will always appreciate all you have done here because I know you are very concerned with our. Print Shop
ReplyDelete