---
title: Script Libraries
slug: v111/script-libraries
icon: {"faIcon":"fa-solid fa-book-open"}
createdAt: 2025-06-10T06:44:31.749Z
---

A Script library allows you to create reusable scripts to run across different server side capabilities of the platform including:

- [Inbound Messaging](docId\:D4gocVxvfJwbgvdIhgo1s)&#x20;
- [Record Generation](docId\:MnV_4TefiY9HLCTj4AV7v)&#x20;
- [System Controllers](docId\:KRCIsVL2mOXebJiydZ_oh)&#x20;

A Script library also helps to abstract complexities that would otherwise be exposed onto the respective platform capabilities mentioned above.

# Creating a script library

| **Field name** | **Field type** | **Description**                                                                                                                                                                                                                                                                          | **Sample value**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| -------------- | -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Name           | String         | Name of the script library                                                                                                                                                                                                                                                               | IncidentUtil                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| Active         | Boolean        | Yes to activate the script library                                                                                                                                                                                                                                                       | Yes                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| Description    | Text           | Use to provide high level information on what the Script library is for.                                                                                                                                                                                                                 | Utility functions for the Incident management process                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| Script         | Script         | Classes and functions available within the Script library.<br />The name of the Script library needs to be the same as the one defined in the script. E.g. IncidentUtil<br />Just like any other server side scripting on the platform, Script library has access to Table API (Server)  | (function (undefined) \{<br />let IncidentUtil = function () \{<br />if (!(this instanceof IncidentUtil)) return new IncidentUtil();<br /><br />return this;<br />};<br /><br />var log = Logger("IncidentUtil");<br /><br />/\*<br />\* Function to find an Incident's related subtasks that are still opened<br />\*<br />\* @Params:<br />\* \_incRec - Table record of an Incident<br />\*<br />\* @Return:<br />\* Array of incident task Table records<br />\*/<br />IncidentUtil.getIncidentOpenTasks = function (\_incRec) \{<br />let retArr = \[];<br /><br />if (\_incRec) \{<br />\_incRec.ParentIncidentForIncidentTasks.forEach(function(\_taskRec) \{<br />if (!\_taskRec.Closed()) \{<br />retArr.push(\_taskRec);<br />}<br />});<br />}<br /><br />return retArr;<br />}<br /><br />// Can add more functions in the same script library<br /><br /><br />// Standard "require" vs "include" type construct<br />if (typeof module !== "undefined" && module.exports) \{<br />module.exports = IncidentUtil;<br />}<br /><br />return IncidentUtil;<br /><br />})();<br /> |

# Calling a Script library

If we are to call a function (called IncidentUtil.getIncidentOpenTasks) on the sample Script Library above on a Trigger for the Incident table, it will look like the following:

```javascript
// ... anything we want to do before calling the script library

let subTaskArr = IncidentUtil.getIncidentOpenTasks(current); // current is an Incident's Table record

// do what we want with subTaskArr
```

