This topic contains 12 replies, has 0 voices, and was last updated by dmashburn3 8 years ago.
-
AuthorPosts
-
October 24, 2016 at 11:02 am #6041
dmashburn3Hi,
This is my first try at running a CSV Import from a file attached to a case. I’m having no trouble pulling the file with a saved search, but I keep getting:
“UNEXPECTED ERROR during CSV Import process” on nlapiSubmitCSVImport()
Here is what I’m working with:
Code:
function importCsvFile(){
var messageSearch = nlapiSearchRecord(“message”,null,
//start by setting up criteria
[
[“subject”,”contains”,”ITEMIMPORT”],
“AND”,
[“messagedate”,”within”,”today”]
],
//and then the results page
[
new nlobjSearchColumn(“internalid”,”attachments”,null)
]
);
for (var i=0;iThis is a cached copy. Click here to see the original post. -
October 24, 2016 at 11:03 am #6042
dmashburn3Also, just to be more clear, the fileId is coming back correct, and the script is executing and says “Complete”, but the execution log shows:
importId =UNEXPECTED ERROR during CSV Import process
-
October 24, 2016 at 11:41 am #6043
david.smithBest way to do CSV imports from script is to first save the CSV Import as a working saved import. You can then just dump your data right to it. Keeping in mind the 25,000 row limitation.
-
October 24, 2016 at 11:43 am #6044
dmashburn3Oh, strange, I thoughts that is what I was doing with the field:
import.setMapping(‘CUSTIMPORTImportItemMapping’);
That is the name of the import that I saved. Should I be calling it differently?
-
October 24, 2016 at 12:16 pm #6045
david.smithTry commenting out the jobName option and change your import.setPrimaryFile(nlapiLoadFile(fileId)); to
Code:
import.setPrimaryFile(fileId); -
October 24, 2016 at 12:30 pm #6046
dmashburn3I tried this line earlier (and just tried again with the setOption commented out) and got this result:
SSS_INVALID_CSV_CONTENT – Input string is not valid CSV content.
I don’t know why it wouldn’t accept fileId, but would accept the nlapiLoadFile(fileId). It seems like they would be the same thing?
-
October 24, 2016 at 12:40 pm #6047
david.smithtry nlapiLoadFile(fileId).getValue()
-
October 24, 2016 at 12:55 pm #6048
dmashburn3That took me back to square one:
-
October 24, 2016 at 1:07 pm #6049
david.smithI just realized “import” is reserved. Try using “job” or something else for your import var.
-
October 24, 2016 at 1:22 pm #6050
dmashburn3That really felt like it was going to be it.
Same thing though.
-
October 24, 2016 at 1:22 pm #6051
dmashburn3Could it be centered around having this set up as a scheduled script? Would that be a problem?
I’m trying to think of any other context that could be causing it. Drawing blanks.
-
October 24, 2016 at 1:47 pm #6052
david.smithHA! Look what I found:
Code:
Warning: You should execute setMapping(savedImport) before any of the other methods. If you try to first execute setPrimaryFile(file), an error is returned.I’m stumped unless you have your “CUSTIMPORTImportItemMapping” ID misspelled or something.
That import does already exist as a saved import, correct? You’re not trying to create it on the fly are you?
-
October 24, 2016 at 2:31 pm #6053
dmashburn3That did it!!!
How did you find that warning?!?!
Interesting that you set the mapping first in the script and then the file, but in the UI its the file and then the mapping.
Thanks so much!
-
AuthorPosts
You must be logged in to reply to this topic.