This topic contains 2 replies, has 0 voices, and was last updated by vandite 6 years, 6 months ago.
-
AuthorPosts
-
May 9, 2018 at 7:56 pm #17944
vanditeHi Everyone
I have created a script which opens a files, formats the file for CSV Import and then triggers a Saved CSV Import.
Code:
var csvImportTask = task.create({taskType: task.TaskType.CSV_IMPORT}); // Create and trigger CSV Import
csvImportTask.mappingId = CSVImportId;
csvImportTask.importFile = csvString;
var csvImportTaskId = csvImportTask.submit();
I then capture the csvImportTaskId within a config file which I source about 30 minutes later to check whether the status is complete or not.The problem that I’m running into is error handling…
ProsIf there is something wrong with the file format or a field value doesn’t match a certain criteria, the csvImportTask.submit() will pick this up and the import will fail and none of the records will be updated.
ConsIf the file is triggered for import successfully, there seems to be no option/parameter available to assign an email address to let me know once the import is complete (like if you were to do the import manually and get that confirmation email once complete)
Regardless of how many records were successful / failed, the status is always COMPLETE.30/30 successfully imported? COMPLETE
15/30 successfully imported? COMPLETE
0/30 successfully imported? COMPLETE
There is no way through task.checkStatus where I can check how many were successful vs failed
There is also no way of checking the results file. Strangely enough in SS 1.0 the equivalent csvImportTask.submit() would return the result.csv file ID (which couldn’t be accessed anyway) and then in SS 2.0, it has been taken away completely.
What I’m wondering from the community is if anyone has been successful in being able to workaround any of the cons above to support any kind of individual record error handling when a CSV Import is triggered. In the short term I’ve been forced to create a map/reduce script instead but ideally I’d like to keep my existing CSV Import design.Any suggestions are appreciated!
Thanks
Patrick
This is a cached copy. Click here to see the original post. -
May 10, 2018 at 12:31 pm #17945
pcutlerA long time ago, using the SuiteScript 1.0 API, I appended the job ID that is returned by nlapiSubmitCSVImport at the end of the CSV response URL (/app/setup/upload/csv/uploadlogcsv.nl?wqid=) and downloaded that file using an NL auth header with a username and password to log in. Then I parsed the CSV file for all the information you’re looking for.
Not sure if that still works, but you could give it a try…
-
May 11, 2018 at 1:21 am #17946
vanditeOriginally posted by pcutler
View Post
A long time ago, using the SuiteScript 1.0 API, I appended the job ID that is returned by nlapiSubmitCSVImport at the end of the CSV response URL (/app/setup/upload/csv/uploadlogcsv.nl?wqid=) and downloaded that file using an NL auth header with a username and password to log in. Then I parsed the CSV file for all the information you’re looking for.
Not sure if that still works, but you could give it a try…
Thanks for your response! I wrote something similar with the nlapiRequestURLWithCredentials but it didn’t seem to work. It wasn’t logging me in correctly so I couldn’t download the file. Would you happen to have your old code lying around somewhere?
Cheers
Patrick
-
AuthorPosts
You must be logged in to reply to this topic.