• adding files when editing a document

    By T Theurer 9 years ago

    The Multiple File Uploader works like a charm, while creating a new document, but when I try to add a file when editing an existing document, the file is attached, but I got an error afterwards:

    Script-Interpreterfehler, Zeile=106, Spalte=26: [TypeError] Beim Aufrufen der Methode NotesDocument ist ein Fehler aufgetreten. copyAllItems(lotus.domino.local.Document, boolean)
       at [/xpFileUploads.jss].moveUploadedFiles(com.ibm.xsp.model.domino.wrapped.DominoDocument@4eea4eea,Attachments)
       105:        //copy all files from the upload document to the target document
    -> 106:         docFiles.copyAllItems( docTo_Backend , true);
       108:        //save the backend document
    Caused by: NotesException: Can't copy a document's items to itself


    The code for the save button:

    document1.replaceItemValue("Log", addLog(document1.getItemValueArray("Log"),context.getUser().getCommonName() +" saved"))
    moveUploadedFiles(document1, "Attachments")

    I've also tried : moveUploadedFiles(currentDocument, "Attachments") with the same result

    viewScope.newDoc is set in the queryNewDocument as described.

    Any ideas ?




    • RE: adding files when editing a document

      By Mark Leusink 9 years ago

      Hello Thomas,

      The actual uploads are performed seperate from the form submission: the files are uploaded to a temporary document and while saving the actual form, the uploaded files are moved (using the moveUploadedFiles) from the temporary document back in the main document.

      The error message you're getting says that items can't be copied to itself: apparantly, docFiles and docBackend_to are the same. I'm not sure how you've implemented the uploader, but in your case you might not need the moveUploadedFiles when editing existing documents.

      By the way: I just retested the sample form in the download in this project and could edit documents without getting the error message you're getting.

      Good luck!