- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-12-2018 08:38 AM
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.
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.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-12-2018 08:42 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-12-2018 08:42 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-12-2018 08:57 AM
Thank you for quick response. Yes, emailing notification will work for me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-12-2018 09:02 AM
Sorry, where I can set Data Source Name in notification?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-12-2018 11:38 AM
Hi, how I can set that data source to this notification unless doing a mailscript with glide record query.