I'm creating a suitelet. I want to include this fi...
# suitescript
s
I'm creating a suitelet. I want to include this file <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.0.272/jspdf.debug.js"></script> When I save, I get Fail to evaluate script: {"type":"error.SuiteScriptModuleLoaderError","name":"UNEXPECTED_ERROR","message":"syntax error (SS_SCRIPT_FOR_METADATA#9)","stack":[]} What am I doing wrong ?
b
probably requires 2.1
and probably a _*require*_ Configuration since the define statement tries to register an alias id
s
Thanks. I'm looking at suiteql, there is a reference to an external file. I think it's something else. I will do more research on the web. Thanks
a
@Simon Any particular reason to use an external library to create PDFs when NetSuite has it own templating system and N/render module to create PDFs?
s
We have a very complex form to create/update (group invoice). As you know, Advanced PDF is quite limited and for this task, Advanced PDF "cannot" do it, the ROI is not realistic. We've been searching for an alternative and we found it Thanks
a
If you use Advanced PDF Templates with SuiteScript and the N/render module you can accomplish anything you want, the use of external library should be your last resort when you are 100% sure you can’t do it with NetSuite and I can tell you for a fact this is not the case. This is only my advice.
👍 2
If you still want to use this you need to make sure you get the UMD or AMD compatible file to include it in the Client Script that you would attach to your Suitelet…
A second option would be to create an inlinehtml field in your Suitelet and using the render module include the library directly from It CDN URL.
s
That's what I did (innerhtml). Now everything is fine You should see the code, it's super simple and we have all the flexibility we needed. We will replace all PDF with this new solution (jsPDF)
a
I don't want to be a negative Nancy here and I really really hate to break this down for you but sadly that is no how the business world works, NetSuite is a System that handles or manipulate finances and that means money, the moment your NOT official library stop working or anything bad happens and your company loses businesses or a big customer your are pretty much fired, specially when NetSuite Support tell and or demonstrate to your boss that native NetSuite functionality could prevent all that.
Again, only an advise... you do what you think is best...
s
Thanks for your comments, but let's say that we agree to disagree Have a great labor day weekend
e
@Simon please do share your code
s
Unfortunately I cannot share the final code but I can share where I start and I'm sure you can complete it So, take the code below, save it in an HTML, run it, and click on Generate PDF using jsPDF Simon <!DOCTYPE html> <html> <head> <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.0.272/jspdf.debug.js"></script> <script> function generatePDF() { var pdf = new jsPDF({ orientation: 'p', unit: 'mm', format: 'a5', putOnlyUsedFonts:true }); pdf.setFontSize(15); pdf.text("Invoice Group #", 90, 20); pdf.setFontSize(10); pdf.text("Samsung",30, 20); pdf.text("3655 North First Street", 30, 25); pdf.text("San Jose, CA 95134", 30, 30); pdf.text("United States", 30, 35); pdf.text("Bill Address",20, 50); pdf.text("One Verizon Way", 20, 60); pdf.text("Basking Ridge", 20, 65); pdf.text("New Jersey, NJ, 07920", 20, 70); pdf.text("United States", 20, 75); pdf.rect(84,55,25,7); pdf.text("Amount Paid",85, 60); pdf.rect(109,55,30,7); pdf.text("$0.00",120, 60); pdf.rect(84,62,25,7); pdf.text("Amount Due",85, 67); pdf.rect(109,62,30,7); pdf.text("$2,688.00",120, 67); pdf.rect(84,69,25,7); pdf.text("Amount Due",85, 74); pdf.rect(109,69,30,7); pdf.text("$2,688.00",120, 74); pdf.addPage(); pdf.setFontSize(30) pdf.text(20, 20, 'The second page'); pdf.save('jsPDF_2Pages.pdf'); // window.open("jsPDF_2Pages.pdf", '_blank'); } </script> </head> <body> <button onclick="generatePDF()">Generate PDF using jsPDF</button> </body> </html>