0
votes

I have a submit only XPage based form that has an inputRichText field for storing screenshots and a multi file upload (using the XPages Multiple File Uploader from OpenNTF) for uploading one or more attachments. When submitted I need both the screenshots and the attachments to appear in a single rich text field which will be accessed via the Notes Client only (non XPages).

Currently the form stores the attachments and screenshots in separate fields. I have tried appending one field to the other on save (using SSJS in the submit button, however because the Screenshots are stored as MIME and the attachments as NotesRichText, it is not letting me do it.

Is there some way (preferably in SSJS) that I can convert either the MIME to RichText or vice versa so that I can append one field to the other? I have tried searching for various solutions to no avail, as well as trying different file upload controls from OpenNTF.

Ideally I need something like this to work:

    var rtItemAttachments:NotesRichTextItem = docTo_Backend.getFirstItem("attachments"); //This is the field I want everything in
    var rtItemFiles:NotesRichTextItem = docTo_Backend.getFirstItem("uploadedFiles");
    rtItemAttachments.appendRTItem(rtItemFiles); //Fails on this line
    docTo_Backend.removeItem("uploadedFiles");
1

1 Answers

1
votes

Speak after me: there is no RichText in the web, all there is is MIME.

You can set the RT field to store its content in MIME (a property). This makes things much easier.

To stitch things together you need to stick with MIME. These are roughly the steps

  • Get the text and images as MIME
  • Get your attachments as stream (the embeddedObjects has a method for that)
  • Convert the stream to BASE64 and create a new mime-part with it. (Looking at an attachment eMail source someone sent through the internet should give you a pretty good idea how it looks like)
  • You end up with:
    • MimeHeader
    • MimePart for Text (HTML)
    • MimePart for Screenshots (if they are not inline images in html)
    • MimeParts for attachments

The special effect: if you add to the HTML with links to the attachments, it looks nicer.

Of course the BIG question: WHY? You could simply design a Notes form that has two fields, no need to fold it into one. Hope that helps.

A good piece of code to look at to understand the MIME stuff is the OpenNTF eMail bean