This topic contains 12 replies, has 0 voices, and was last updated by dmashburn3 8 years ago.

  • Author
    Posts
  • #6041

    dmashburn3

    Hi,

    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.

  • #6042

    dmashburn3

    Also, 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

  • #6043

    david.smith

    Best 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.

  • #6044

    dmashburn3

    Oh, 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?

  • #6045

    david.smith

    Try commenting out the jobName option and change your import.setPrimaryFile(nlapiLoadFile(fileId)); to

    Code:
    import.setPrimaryFile(fileId);

  • #6046

    dmashburn3

    I 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?

  • #6047

    david.smith

    try nlapiLoadFile(fileId).getValue()

  • #6048

    dmashburn3

    That took me back to square one:

  • #6049

    david.smith

    I just realized “import” is reserved. Try using “job” or something else for your import var.

  • #6050

    dmashburn3

    That really felt like it was going to be it.

    Same thing though.

  • #6051

    dmashburn3

    Could 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.

  • #6052

    david.smith

    HA! 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?

  • #6053

    dmashburn3

    That 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!

You must be logged in to reply to this topic.