Import data via a Record producer and generate/ display a message on the screen with detailed results of how many records are inserted / ignored/updated

Adithi2
Tera Contributor

Hello,

I want to import data from external file expected it would be excel file. This I have implemented using the record producer where solution enables users to submit a record producer with an attached excel document which generates a data source and triggers one or many transform maps. Below is the script used in record producer:

I have two queries here:

1. Following a successful transform, message must be displayed on the screen containing the results of their transforms like how many records are inserted / updated / ignored etc.. I do not want email notification, I just want a simple message to be displayed on the screen

2. I see  this code will generate data source every time. I need to use the same data source all the time with the latest attachment.

Please assist on this.

var transformMapSysIDs= 'bedc1fb21b909d5085eb64a2604bcbea';
current.name = gs.getUserName() + " User Import at: " + new GlideDateTime();
current.import_set_table_name = 'u_mass_multimedia_device'; //name of import set table
current.file_retrieval_attachment =  "Attachment";
current.type = "File";
current.format = "Excel";
current.header_row = 1;
current.sheet_number =1;
current.insert(); // Need this to load & transform directly

//Time to load excel file into import table

var loader = new GlideImportSetLoader();
var importSetRec = loader.getImportSetGr(current);
var ranload = loader.loadImportSetTable(importSetRec, current);
importSetRec.state = "loaded";
importSetRec.update();

//Time to run transform with transform map
var transformWorker = new GlideImportSetTransformerWorker(importSetRec.sys_id,transformMapSysIDs);
transformWorker.setBackground(true);
transformWorker.start();

gs.addInfoMessage("Your import file has been submitted.");

//To avoid to create another data source we abort RP insert
current.setAbortAction('true');

---------------------------------------------------------------------------------------------------------------------------------------------

 

 

Thanks

Adithi