How to bring external library to ServiceNow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2023 08:56 AM - edited 01-23-2023 12:04 PM
How would I bring the bignumber library, which is essentially a javascript file, to ServiceNow so I could use it in my scripting? https://github.com/MikeMcl/bignumber.js/blob/master/bignumber.js
UPDATE (1/23/2023): Please check out this link to learn how to import external libraries and test their functionality https://www.servicenow.com/community/developer-blog/mini-lab-adding-underscore-js-into-servicenow/ba...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2023 10:12 AM
There are a few different ways to bring the BigNumber library, which is a JavaScript file, to ServiceNow so you can use it in your scripting. Here are a few options:
Script Include: One option is to create a new Script Include in ServiceNow, and then copy the contents of the BigNumber library JavaScript file into the Script field. Once you've done this, you can reference the Script Include in your scripts by calling the appropriate methods.
UI Script: Another option is to create a new UI Script record in ServiceNow, and then copy the contents of the BigNumber library JavaScript file into the Script field. Once you've done this, you can reference the UI Script in your UI pages by including the appropriate reference to the script.
External Script: You can also include the BigNumber library script externally, by providing a URL to the script. This method is useful when you want to reference a version of the library that is not hosted in your instance. You need to be careful when using this method, as it can be affected by cross-site scripting (XSS) vulnerabilities.
It's worth mentioning that some of these options may require some knowledge of JavaScript, HTML and CSS, and it's important to ensure that the library is compatible with your version of ServiceNow and to test it in a non-production instance before deploying it to production to ensure it works as expected and prevent any data loss or unexpected results.
Kindly mark the response as Correct or Helpful.
Cheers,
Anish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2023 10:18 AM
Hi Anish, thanks for responding!
For the Script Include method, would it be a simple copy/paste? Or would I need to change the syntax of the original code to make it work in ServiceNow?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2023 10:21 AM
It won't be a simple copy/paste. You will have to work out the syntax, but if you have worked on Script include, should not be much of effort.
Cheers,
Anish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2023 10:23 AM
Okay, thank you!