How to use ExcelJS in Scheduled Script

Renee-17
Tera Guru

I'm trying to create a report that is formatted into table with a couple of worsheets in an excel workbook and found a post where someone suggested using ExcelJS.

 

Being new to JavaScript and ServiceNow, I'd like to know... Is it possible to include ExcelJS in a newly created script that I'm creating via selecting "All > System Definition > Scheduled Jobs > New > Select Automatically run a script of your choosing".

 

If so, how do I make ExcelJS accessible to the new scheduled script I'm creating?

4 REPLIES 4

Renee-17
Tera Guru

Maybe a better question is... Where do you load the npm packages in ServiceNow so they can be used in a JavaScript include statement?

eduardo gushike
Tera Contributor

any update guys?

Ajay_Chavan
Kilo Sage
Unfortunately, you cannot directly include ExcelJS (or most external JavaScript libraries) in ServiceNow scheduled scripts in the traditional way you might expect. Here's why and what you can do instead:
Why ExcelJS Won't Work Directly
ServiceNow runs on a server-side Rhino JavaScript engine that doesn't support:

NPM package imports
Modern ES6+ module syntax (import/require)
Many Node.js-specific APIs that ExcelJS depends on
Glad I could help! If this solved your issue, please mark it as Helpful and Accept as Solution so others can benefit too.*****Chavan A.P. | Technical Architect | Certified Professional*****

Rafael Batistot
Kilo Patron

Hi @Renee-17 

 

To handle excel sheets in ServiceNow, may you try via GlideExcelParserScoped

 

In this document you be able to learn how to handle with a sheet or several one 

 

https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/...

 

If you want to load an excel in certain specific table may you try via Transform map 

 

https://www.process.st/how-to/create-a-transform-map-in-servicenow/