This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Sep 11, 2012, 11:13 AM
25 Posts

RichText - Retrieve/Update via SSJS

  • Category: Server Side JavaScript
  • Platform: Windows
  • Release: 8.5.2
  • Role: Developer
  • Tags:
  • Replies: 1

Hi,

Can anyone guide me how to populate rich text data from back end document to “Rich Text” component on x page and save the changes from x page component (front end) to back end rich text  field on document through SSJS.

Thanks in advance.

Sep 12, 2012, 12:27 AM
4 Posts
Re: RichText - Retrieve/Update via SSJS
  1. Set your Rich Text field to  "Store contents as HTML and MIME".
  2. Bind your Rich Text control to a scoped variable (requestScope.Body).
  3. AddSSJS to afterPageLoad event.
    1. var entity:NotesMIMEEntity = document1.getDocument().getMIMEEntity("Body");
    2. if (entity != null) {
    3.     requestScope.Body = entity.getContentAsText();
    4. }
Then in your querySaveDocument you can call a function similar to the one below:
 
function updateBody( doc:NotesDocument ){   
    if (requestScope.Body != null) {
        //requestScope.body is bound to an inputRichText control
        var body:com.ibm.xsp.http.MimeMultipart = requestScope.Body;
        var stream:NotesStream = session.createStream();
        stream.writeText(body.getHTML());
       
        var entity:NotesMIMEEntity = doc.getMIMEEntity("Body");
        entity.setContentFromText(stream,"text/html;charset=US-ASCII", 1725);
        stream.close();
    } else {
        requestScope.status = "no content";
    }
}

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal