Hi everyone! Is there a way to download in PDF all...
# suitescript
k
Hi everyone! Is there a way to download in PDF all Sales Orders and Invoices? Using the Print Checks and Forms only lets me do 100 at a time and I have over 55,000. One of our companies is stepping away from NetSuite and we want to export these in a PDF format. Thank you!
a
You may need a Map Reduce Script that generate those PDFs one by one via the render module and store then in the file Cabinet. Then you need a way to download those, not sure if NetSuite file cabinet will allow you to download a folder with 55k files.
e
If using a Map/Reduce, create sub-folders by year or something sensible to split the folder size, but easy to download.
k
This is the script I used/found from a Reddit post:
function Create_Pdf_files(recType, recordInternalId) {
try {
nlapiLogExecution('debug', "Printing " + recType + " Internal ID " + recordInternalId);
var transNumber = nlapiLookupField('transaction', recordInternalId, 'transactionnumber');
var fileName = transNumber + '.PDF';
var Pdf_Object = nlapiPrintRecord('TRANSACTION', recordInternalId, 'PDF');
Pdf_Object.setFolder(XXX); // <--- Replace 'XXX' with the internal ID of the folder where you want to save the PDFs.
Pdf_Object.setName(fileName);
nlapiSubmitFile(Pdf_Object);
// nlapiSendEmail(XXX,XXX,'This Record Has Been Printed','Test','<mailto:your_email_address@gmail.com|your_email_address@gmail.com>',null); // <--- Uncomment this line to send an email notification.
} catch (err) {
nlapiLogExecution('debug', "Error Printing " + recType + " Internal ID " + recordInternalId, err);
}
}
a
That is just a function that needs each transaction ID and using SS 1.0. You are going to need a Map Reduce that will: • Search for the transactions to be printed. • Return an array of internal IDs in the getInputData stage. • In the map stage process each PDF with the render module and save it to the folder or folders in the file cabinet. I don’t want to sound like a negative Nancy here but a word of advice, copy pasting code that you don’t understand to accomplish something could be a double edge sword aka a shortcut to getting fired if something goes wrong, specially in a financial system such as an ERP.
k
Oh definitely I agree with you. It was only used in sandbox, but still I understand what you're saying
t
@Koon Kabob This is a great example of why I'm developing Suite.js ( https://suitejs.io ). If you're interested in being a case study for it, DM me.
👀 1
s
curious why you picked ducktape as the JS engine for suitejs.io?
t
@Shawn Talbert In no particular order, here's why I went with Duktape: • It's easy to work with. • It starts up very quickly. • It has a very small footprint, and being able to run Suite.js on resource-constrained devices is important to me. • It's extremely stable. • I have a lot of experience working with it. The "catch" is that while it supports ECMAScript E5/E5.1, it only partially supports ECMAScript 2015 (E6) and 2016 (E7). But for the types of apps Suite.js is intended to be used for, those limitations typically aren't a problem. That all being said, Suite.js isn't going to resonate with everyone. If you're already using and comfortable with a JS runtime such as Node, Deno, or Bun, then you'll probably want to stick with it. But if not - or if, like me, you're not a fan of those runtimes and the baggage that comes with them - then you might want to take a look at Suite.js. (When it actually ships, of course. Ha!)
👍 1
😍 1