Issue with Staging Table Record Creation & Running Only One Transform Map
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2025 05:47 AM
Hi All,
I’m working on a requirement where records are sent to a staging table and then processed through a specific transform map.
However, I’m facing two issues:
When I insert a record into the staging table via script, it is being created twice.
When running the transform, all transform maps associated with the staging table are executed instead of just the one I want.
Here’s the script I’ve been working with:
var stagtable = new GlideRecord("staging_table");
stagtable.initialize();
stagtable.u_first_name = "test123";
stagtable.setWorkflow(false);
var it = new GlideImportSet("staging_table");
it.setSynchronous(true);
stagtable.sys_import_set = it.create();
var rgr = new GlideRecord('sys_import_set_row');
rgr.orderByDesc("sys_import_row");
rgr.setLimit(1);
rgr.addQuery('sys_import_set', stagtable.sys_import_set);
rgr.query();
if (rgr.next()) {
stagtable.sys_import_row = rgr.sys_import_row + 1;
} else {
stagtable.sys_import_row = 0;
}
stagtable.insert();
var importSetGr = new GlideRecord("sys_import_set");
importSetGr.get(stagtable.sys_import_set);
var importSetId = importSetGr.getUniqueValue();
var importSetRun = new GlideImportSetRun(stagtable.sys_import_set);
var importLog = new GlideImportLog(importSetRun, "SOAP Transform");
var ist = new GlideImportSetTransformer();
ist.setLogger(importLog);
ist.setImportSetRun(importSetRun);
ist.setImportSetID(importSetId);
ist.setSyncImport(true);
ist.transformAllMaps(importSetGr, stagtable.getUniqueValue());
So here I have two table transform map which is being used on two different target tables
but when try to run the specific transform map it is not working
UseCase: The data is coming from 3rd party i have two add that in user table and hr profile table both are from different API's actually due to similar fields I am using single staging table
1. When both the transform maps are active two records will be created on stagting table, import set run table as well with both transform maps.
How do I make sure the staging record is created only once? when i insert one record and is there any way we can run specific transform table for that record
Thanks in advance
Regards,
Prajwal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2025 06:08 AM
you are inserting via script using insert() and import set will also create an entry
where have you written this script?
are you pulling data from some 3rd party API and then inserting data?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2025 06:16 AM
something like this will help
// 1. Create Import Set record for staging table
var importSet = new GlideImportSet('staging_table');
importSet.setSynchronous(true);
var importSetSysId = importSet.create();
// 2. Insert import set row(s) tied to the import set
var importSetRowGR = new GlideRecord('sys_import_set_row');
importSetRowGR.initialize();
importSetRowGR.setValue('sys_import_set', importSetSysId);
importSetRowGR.setValue('u_first_name', 'test123'); // Column in staging table
// Set additional staging table fields as needed
importSetRowGR.insert();
// 3. Load import set to process rows
var importSetGR = new GlideRecord('sys_import_set');
importSetGR.get(importSetSysId);
// 4. Prepare to run a specific transform map
var transformer = new GlideImportSetTransformer();
transformer.setImportSetID(importSetSysId);
transformer.setSyncImport(true);
// Replace with the sys_id of your specific transform map you want to run
var specificTransformMapSysId = 'your_transform_map_sys_id_here';
// 5. Run the specific transform map on the import set
transformer.transform(specificTransformMapSysId, importSetSysId);
// Optional: check status or logs after transform
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2025 08:08 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2025 11:39 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader