GlideImportSetLoasder and GlideImportSetTransformer API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hi Community,
I’m working on a requirement within a scoped application where I need to automate the “Load Data” process from a Data Source using script, and then programmatically trigger the associated Transform Map to move the data into the target table.
My initial approach was to use the GlideImportSetLoader and GlideImportSetTransformer APIs. However, while testing the script in Scripts - Background, I encountered an issue: both of these APIs are flagged as belonging to the global scope, which prevents me from using them within my scoped app.
Has anyone faced a similar limitation?
What is the recommended approach or alternative to automate import + transform execution from a scoped application?
Any guidance or best practices would be greatly appreciated.
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Hi,
This behavior is expected because the GlideImportSetLoader and GlideImportSetTransformer APIs belong to the Global scope, which means they cannot be directly accessed from a Scoped Application.
A common and recommended approach is to create a Script Include in the Global scope that performs the import and transform operations, and then call that Script Include from your scoped application.
For example:
Create a Script Include in the Global scope:
var ImportSetUtils = Class.create();
ImportSetUtils.prototype = {
initialize: function() {},
runImportAndTransform: function(dataSourceSysId) {
var dataSource = new GlideRecord('sys_data_source');
if (dataSource.get(dataSourceSysId)) {
var loader = new GlideImportSetLoader();
var importSetGr = loader.getImportSetGr(dataSource);
loader.loadImportSetTable(importSetGr, dataSource);
var transformer = new GlideImportSetTransformer();
transformer.transformAllMaps(importSetGr);
}
},
type: 'ImportSetUtils'};
From your Scoped Application, call the Script Include:
var utils = new global.ImportSetUtils();
utils.runImportAndTransform('DATA_SOURCE_SYS_ID');
This approach keeps the import logic in the Global scope where the APIs are accessible, while still allowing your scoped application to trigger the process programmatically.
Hope this helps.
