How to fix multiple History record creation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi All,
I Know this is expected behaviour, through the script when we are inserting data into import table(staging table) automatically data updated in target table records and for each record seperate Transform history created , means if 10 records created in staging table for those 10 records, one Import Set record (sys_import_set), 10 transform history records created (sys_import_set_run) .
Transform map:
Run business rule=false
if(insert=='insert'){ ignore=true; }
coalesce=true, u_umber-->number
Concern: can we control it & can we get only one sys_import_set_run to all this process?
How to fix this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @Supriya25 what your trying perform or trying,I don’t think so we can do it, because there is no supported way to force a single sys_import_set_run for multiple source records.
However, depending on the requirement, here are a few possible workarounds:
1. Try Disabling auto-transform and trigger the transform once
Insert records into the import table with auto-transform disabled
Trigger the transform manually using one of the following:
Scheduled Import
Scripted transform (GlideImportSetLoader / GlideImportSetTransformer)
but even with this approach, Snow will still create one sys_import_set_run per row.
2. We try using a single source record
Insert only 1 record into the import table
Store multiple records as JSON or XML in that single record
Process the data in an onAfter transform script
This will requires custom logic, but this will results in only one visible transform execution.
3. Reporting / cleanup approach
Use sys_import_set for reporting instead of sys_import_set_run
Archive or filter transform history if UI clutter is the main concern
These are the possible workarounds you can try, So which option makes sense really depends on your requirement.
If you find this useful, kindly mark it as Accept as Solution and Helpful.
Regards,
- Ankit
LinkedIn: https://www.linkedin.com/in/sharmaankith/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Hi Ankit,
Thanks for your reply,
https://www.servicenow.com/docs/bundle/washingtondc-api-reference/page/app-store/dev_portal/API_refe...
var transformer = new GlideImportSetTransformer();
transformer.transformAllMaps(importSetGr);
var importSetSysId = "";
for (var i = 0; i < 10; i++) {
var rec = new GlideRecordSecure('u_staging_table');
rec.initialize();
rec.u_number = 'INC00' + i;
var rowSysId = rec.insert();
// Capture the import set ID from the first inserted row
if (i === 0) {
var r = new GlideRecord('u_staging_table');
r.get(rowSysId);
importSetSysId = r.sys_import_set.toString();
}
}
var transformer = new GlideImportSetTransformer();
transformer.transformAllMaps(importSetSysId);is this way you are saying ?
does it work for HRSD application ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi Supriya,
Yes, this was the approach I was referring to, When you insert records into the staging table without auto-transform, all the rows are grouped under a single sys_import_set. Calling GlideImportSetTransformer.transformAllMaps(importSetSysId) will trigger the transform once for that import set instead of per insert
However, it’s important to clarify that even with this approach, ServiceNow will still create one sys_import_set_run record per source row. This was expected platform behavior and cannot be changed. Triggering the transform once only gives you control over when the transform runs and it does not reduce the number of transform history records.
And regarding HRSD, this approach works as long as you are using a standard import set table and have the required roles. HRSD tables are usually scoped and secured, so permissions and application scope need to be considered, but you know the import set and transform mechanism itself behaves the same.
Hope this helps, If you find this useful, kindly mark it as Accept as Solution and Helpful.
Regards,
- Ankit
LinkedIn: https://www.linkedin.com/in/sharmaankith/
