GlideImportSetLoader and GlideImportSetTransformer in ServiceNow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
In complex ServiceNow implementations, bulk data loads from external sources are a common requirement — whether for configuration data, CMDB population, or integrations. Generally, we use UI buttons to load and transform the data into the ServiceNow table. This is the most common approach followed by many ServiceNow developers. However, if there's a requirement to upload a file through the Service Portal or a Catalog Item, and with a single click the data should be transformed into the target table — this can be achieved using scripting.
In one of my recent tasks, I automated data loading and transformation using two powerful ServiceNow server-side APIs: GlideImportSetLoader and GlideImportSetTransformer. These APIs allow you to programmatically handle file imports, create import set records, and execute transformation maps — all without relying on UI-based actions. This approach is particularly useful in scenarios where user interaction is limited to uploading a file through the Service Portal or Catalog Item, and the backend needs to handle everything seamlessly.
By using GlideImportSetLoader, I was able to read the uploaded file and generate an import set record behind the scenes. Once the file was loaded, GlideImportSetTransformer helped me invoke the associated transform map to convert the raw data into records in the target table. This method not only improved user experience by eliminating manual steps but also made the process more efficient and scalable.
This article will walk you through How these APIs — GlideImportSetLoader and GlideImportSetTransformer are useful, and where they are particularly helpful. You'll gain an understanding of how they function, their role in streamlining data imports, and the scenarios where using them can significantly enhance automation and efficiency in your ServiceNow implementations.
How These APIs Are Useful?
- Need to Automate Imports Without Manual Clicks: The UI requires a human to manually upload a file and click "Load Data" and "Transform". With GlideImportSetLoader and GlideImportSetTransformer, you can automate the entire process — ideal for: Scheduled Jobs that run every night Catalog Items where users upload Excel/CSV files Event-driven flows (e.g., file received via integration)
- User Uploads via Portals or Catalog Items: When users submit data files via Service Portal or a Catalog Item, the UI doesn’t automatically know how to load or transform that data.
Where Are These APIs Helpful?
These APIs are especially useful in automated and user-driven scenarios where you need more control than what the UI offers.
Use Cases:
- Catalog Item File Uploads Trigger data import and transformation when a user submits an Excel/CSV file through a catalog item.
- Service Portal Uploads When users upload files via a widget or form in the Service Portal, the file can be passed to the server using GlideImportSetLoader to create an import set record, and then transformed immediately using GlideImportSetTransformer — without needing any manual UI interaction.
- Automated Integration Points These APIs are useful when a file is received from external systems (via REST API, email, or file drop), and you want to load and transform that file automatically using a Scheduled Job, Flow, or Scripted REST API — all handled via scripting without UI involvement.
Understanding How These APIs Work
GlideImportSetLoader
- The GlideImportSetLoader class is used to programmatically load data from a Data Source into an Import Set table in ServiceNow.
- Think of it as the script-based equivalent of clicking the "Load Data" button in the UI.
Key Methods
- getImportSetGr(dataSourceRecord): Creates a new Import Set record (sys_import_set) based on the provided Data Source record.
- loadImportSetTable(importSetRecord, dataSourceRecord): Loads the data from the file attached to the Data Source into the Import Set table using the ImportSet and Data Source records.
Sample Code:
var loader = new GlideImportSetLoader();
var importSetRec = loader.getImportSetGr(dataSourceGr);
loader.loadImportSetTable(importSetRec, dataSourceGr);
GlideImportSetTransformer
- The GlideImportSetTransformer class is used to transform data from the Import Set table into the target table using one or more associated Transform Maps.
- It is the script-based equivalent of clicking the "Transform" button in the UI.
Key Methods
- transformAllMaps(importSetRecord): Transforms the data in the given Import Set GlideRecord by executing all associated Transform Maps.
Sample Code:
var transformer = new GlideImportSetTransformer();
transformer.transformAllMaps(importSetRec);
GlideImportSetLoader and GlideImportSetTransfomer make it much easier to automate and control the data import process in ServiceNow. They save time and reduce manual effort when working with large or recurring data loads.
- 53 Views