Tuesday, July 9, 2019

PDF file created via nlapiPrintRecord being saved with '.bin' extension

When creating a file using script nlapiPrintRecord API is normally used to create the file object of a transaction. It includes a third parameter that specify the file type. The script below will create a file with a custom filename based on a value of a field, but the file created will result to an extension of .bin
var pdf = nlapiPrintRecord('TRANSACTION', poID, 'PDF', {'formnumber':'108'});pdf.setFolder('853');pdf.setName(poNumber + '-' + nlapiLookupField('purchaseorder', poID,'custbody_po_version_num'));nlapiSubmitFile(pdf);

To avoid this, developers should include the file extension on the file name as well when setting the name of the file using setName. Please check the sample code below as guide.

var pdf = nlapiPrintRecord('TRANSACTION', poID, 'PDF', {'formnumber':'108'});pdf.setFolder('853');pdf.setName(poNu0mber + '-' + nlapiLookupField('purchaseorder', poID,'custbody_po_version_num') +'.pdf');nlapiSubmitFile(pdf);

No comments:

Post a Comment