- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2025 04:49 AM
I added an action to register the CSV file into the database after attaching it, and although the file in the Data Source was updated, the contents of the CSV were not reflected as data in the database.
In the flow, I set att_sys_id (the sys_id of the attached file) as an input.
javascript
(function execute(inputs, outputs) {
// Data Source sys_id
var grDataSource = new GlideRecord("sys_data_source");
// DATA SOURCE SYS ID
if (!grDataSource.get('175768c183eb6290d751a270ceaad389')) {
gs.error("no data source");
return;
}
gs.info("test1111111111");
// Import Set
var loader = new GlideImportSetLoader();
var importSetGr = loader.getImportSetGr(grDataSource);
gs.info("test222222222");
loader.setAttachmentId(inputs.att_sys_id); /
loader.loadImportSetTable(importSetGr, grDataSource);
gs.info("test3333333333");
var importSetRun = new GlideImportSetRun(importSetGr.sys_id);
var importLog = new GlideImportLog(importSetRun);
var importTransformer = new GlideImportSetTransformer();
importTransformer.setLogger(importLog);
importTransformer.setImportSetRun(importSetRun);
//importTransformer.setImportSetID(importSetGr.sys_id);
importTransformer.setSyncImport(true); // If true, script will wait for transform to finish
importTransformer.transformAllMaps(importSetGr);
gs.info("test44444444444");
})(inputs, outputs);
Solved! Go to Solution.
- Labels:
-
Tokyo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2025 06:15 AM
Did the data get loaded in staging table?
is that data source having a transform map associated with it for your target table?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2025 05:51 PM
Thank you for your response. The issue has been resolved.
Added processing to set the attachment file to the data source.
// source
var gsa = new GlideSysAttachment();
gsa.deleteAll(ds);
gsa.copy('sc_req_item', reqitemSysId, 'sys_data_source', dataSourceSysId);
fixAttachmentTableName(dataSourceSysId);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2025 06:15 AM
Did the data get loaded in staging table?
is that data source having a transform map associated with it for your target table?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2025 05:51 PM
Thank you for your response. The issue has been resolved.
Added processing to set the attachment file to the data source.
// source
var gsa = new GlideSysAttachment();
gsa.deleteAll(ds);
gsa.copy('sc_req_item', reqitemSysId, 'sys_data_source', dataSourceSysId);
fixAttachmentTableName(dataSourceSysId);