Tutorial part 4: Install and use a third-party library
Install a third-party library from Node Package Manager (npm) and use it in a JavaScript module.
Before you begin
Complete Tutorial part 3: Define a table in ServiceNow Fluent code.
Role required: admin
About this task
Installing third-party libraries allows you to use existing open-source functionality in JavaScript modules to accelerate application development. Then you can refer to JavaScript modules that call third-party code from server-side script definitions in your source code, such as the business rule in the index.now.ts file.
In this example, you install a Lodash library to get common JavaScript utilities and methods. You use one of these methods, snakeCase, in the showStateUpdate function in a sample JavaScript module to display a message string in snake case, which separates words with underscores instead of spaces. In the index.now.ts file, the sample business rule is configured to use the showStateUpdate function for its script and to run after a record is updated in the To-do Items [x_snc_hello_world_to_do] table.
Procedure
Result
After you update any field on a record in the To-do Items [x_snc_hello_world_to_do] table, the sample business rule runs and displays the message in snake case, with the words separated by underscores instead of spaces.
What to do next
Continue to Tutorial part 5: Clone the application on a different instance.