How to fix multiple History record creation

Supriya25
Tera Guru

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.


2 REPLIES 2

Ankith Sharma
Giga Guru

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/

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();
.........................
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 ?