Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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?

5 REPLIES 5

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?

Hello @Renee-17 ,

 

Have you managed to somehow run ExcelJS via scheduled jobs?

I need to send periodic reports with customizations, but I haven't found a solution.

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*****