ImportSet Error Messages

questsal78
Giga Expert

Hi,

I'm using a record producer to import data into a custom table for updates. Everything is working fine except, I'm unable to show end user a message showing how many rows were there, how many are updated and how many ignored just like below: End user is not admin so they can only see messages via record producer.

find_real_file.png

Here is my code:

// Set the following variables with the name of your import set table and task id column

var importSetTableName = "u_integrate_renewal_orders";

var transformMapID = "xxxxxxxxxxxxx"; // removed actual sys_id with text

// Setup data source for attachment

current.name = "Renewal Import " + now();

current.import_set_table_name = importSetTableName;

current.file_retrieval_method = "Attachment";

current.type = "File";

current.format = "Excel";

current.header_row = 1;

current.sheet_number = 1;

current.insert();

// Process excel file

var loader = new GlideImportSetLoader();

var importSetRec = loader.getImportSetGr(current);

var ranload = loader.loadImportSetTable(importSetRec, current);

importSetRec.state = "loaded";

importSetRec.update();


// Transform import set

var transformWorker = new GlideImportSetTransformerWorker(importSetRec.sys_id, transformMapID);

transformWorker.setBackground(true);

transformWorker.start();

// Take user to task

gs.addInfoMessage("Data import may take time load, please reload record to see all the assets.");



// Since we inserted data source already, abort additional insert by record producer

current.setAbortAction(true);

I don't know how to get this information from import set/transform map for end user. Is there a way to achieve this in record producer script?

Please advise.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Since the transform may take long time depending on the import set rows you can't force the user to stay on the same page.

Why not send an email notification instead with details:

total records

ignored

skipped

inserted

updated

Notification table: 

Transform History [sys_import_set_run]

Trigger condition: State is one of Complete or Complete with errors

Set.Data Source.Name => your data source name

template.print("Total:"+current.total+"<br/>");
template.print("Inserts:"+current.inserts+"<br/>");
template.print("Updates:"+current.updates+"<br/>");
template.print("Ignored:"+current.ignored+"<br/>");
template.print("Skipped:"+current.skipped+"<br/>");
template.print("Errors:"+current.errors+"<br/>");

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Since the transform may take long time depending on the import set rows you can't force the user to stay on the same page.

Why not send an email notification instead with details:

total records

ignored

skipped

inserted

updated

Notification table: 

Transform History [sys_import_set_run]

Trigger condition: State is one of Complete or Complete with errors

Set.Data Source.Name => your data source name

template.print("Total:"+current.total+"<br/>");
template.print("Inserts:"+current.inserts+"<br/>");
template.print("Updates:"+current.updates+"<br/>");
template.print("Ignored:"+current.ignored+"<br/>");
template.print("Skipped:"+current.skipped+"<br/>");
template.print("Errors:"+current.errors+"<br/>");

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Thank you for quick response. Yes, emailing notification will work for me.

 

 

Sorry, where I can set Data Source Name in notification?

Hi, how I can set that data source to this notification unless doing a mailscript with glide record query.