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


Nov 11, 2016, 12:09 PM
2 Posts

Backend RichText fields

  • Category: Application Development
  • Platform: Windows
  • Release: 9.0.1
  • Role: Developer
  • Tags: RichText,backend
  • Replies: 4

Hi, I'm sure this will have been asked a thousand times before, but I can't find a definitive answer anywhere. I've been struggling for over a week now, and still can't get this working. Here's hoping!

I have a richtext field on a form (a profile document although I don't think that matters). When I add to the field in the UI and save, the content is saved (as expected). If, however, I obtain a handle from uidoc.document to the backend and append some text programmatically to the field. Seemingly no combination of rti.update, uidoc.refresh, uidoc.reload etc. will convince the backend changes to be included in the frontend (even after saving and reopening), although the field changes made through the UI are preserved. Here's a summary of the code in the querysave event for the form. Please could you have a look and offer some explanation/alternative code?

 Dim wksp As New NotesUIWorkspace
 Dim uidoc As NotesUIDocument
 Dim doc As NotesDocument
 Dim rti As NotesRichTextItem
 Set uidoc = wksp.CurrentDocument
 Set doc = uidoc.Document
 Set rti = doc.GetFirstItem("theLog")
 rti.Appendtext "Something to be added to the log"
 rti.update
 uidoc.refresh true

 

Nov 11, 2016, 9:43 PM
82 Posts
something like this might help ....
 doc.saveoptions="0"
Set rti = doc.GetFirstItem("theLog")
rti.Appendtext "Something to be added to the log"

Call uidoc.Close(True)
Set newUIDoc = uiws.EditDocument(True,doc,False,,,True)
Delete uiDoc
Call newUIDoc.Document.ReplaceItemValue("SaveOptions","1")
Nov 14, 2016, 8:41 AM
2 Posts
Backend RichText fields - Retaining user edits but not programmitic.

Thanks Bob,

That's how my code was to begin with (from an IBM article on how to update richtext fields on-screen). When I came up with problems however, I reverted to the code which would require a save, close and re-open. In both cases, however, the richtext field retained the UI edits but NOT the programmatic ones.

So when I use your code, user edits show up, as does the programmatic ones - All Good! When I save and re-open though, the programmatic changes are missing whilst the user edits remain.

Nov 14, 2016, 8:45 PM
59 Posts
a slightly different approach...

I use this kind of sequence to solve this problem:

    x$ = doc.NoteID
    Call wks.CurrentDocument.Close(True)
    Delete doc
    Set doc = wks.CurrentDatabase.Database.GetDocumentByID(x$)
    Set uidoc =  wks.EditDocument(True, doc, , , , True)

Perhaps that will help? I think the difference is that the doc object is completely deleted.

Nov 20, 2016, 11:25 AM
21 Posts
Not saving the backend document?

I don't see anywhere in your code where you're saving the backend NotesDocument object after appending text to the rich text field.

After calling rti.Update save the Doc object.   You will need to close the uidocument and then re-open the backend document:

 

Dim wksp As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim Db As NotesDatabase
Dim doc As NotesDocument
Dim rti As NotesRichTextItem
Dim NoteID As String

Set uidoc = wksp.CurrentDocument
Set doc = uidoc.Document
Set Db = doc.ParentDatabase

Set rti = doc.GetFirstItem("theLog")
rti.Appendtext "Something to be added to the log"
rti.update
Call doc.Save(True, True)
Delete rti

NoteID = doc.NoteID

Call uidoc.Close(True)

If Not uidoc Is Nothing Then
    Delete uidoc
End If

If Not doc Is Nothing Then
    Delete doc
End If

Set doc = Db.GetDocumentById(NoteID)
If Not doc Is Nothing Then
    Call wksp.EditDocument(True, doc, False)
End If

 

 


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