- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2023 11:32 AM
Hi All,
We have one record producer (table= data source ) where one attachment is attached to it and below script is written in script section.
what this script is doing. Please explain.
var transformMapSysIDs = 'f63d80a0db88b810c05f2706ca9999d';
current.name = gs.getUserName() + " UserImport at: " + new GlideDateTime();
current.import_set_table_name = 'u_stm_task_bulk_upload';//Name of your import table
current.file_retrieval_method = "Attachment";
current.type = "File";
current.format = "Excel";
current.header_row = 1;
current.sheet_number = 1;
var sysid = current.insert();//Need this since we want to load and transform directly
//Now it time to load the excel file into the 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 the the transform with the transform map
var transformWorker = new GlideImportSetTransformerWorker(importSetRec.sys_id, transformMapSysIDs);
transformWorker.setBackground(true);
transformWorker.start();
//To avoid to create another data source we abort the RP insert.
current.setAbortAction(true);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2023 12:06 AM
Hello,
So, the above script works to create the records in a ServiceNow table. Seems you will have a transform map with sysid 'f63d80a0db88b810c05f2706ca9999d' already available in your system. So when the any excel is attached the data source and transform map will run and the data in the excel will create/update record in the target table.
Please mark my answer as correct based on impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2023 12:06 AM
Hello,
So, the above script works to create the records in a ServiceNow table. Seems you will have a transform map with sysid 'f63d80a0db88b810c05f2706ca9999d' already available in your system. So when the any excel is attached the data source and transform map will run and the data in the excel will create/update record in the target table.
Please mark my answer as correct based on impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2023 01:25 AM
Hello,
If my answer helped you can you also mark it as correct.
Thanks.