0
votes

Ok, I have a form that contains several RichTextFields. In the PostOpen event of the form, I am rebuilding several RichTextTables. In addition, I have a button on this form to change some of the information contained in these RichTextTables.

First Case: The first time the document is opened, the RichTextTables do not display. Each time the document is opened thereafter, it displays just fine. I suspect that it is taking an open, a close and another open to display the RichTextTables correctly. I could use some help in getting them to display the first time.

Second Case: The routine that is called in the PostOpen to do this rebuild is also called from a button on the form that allows the user to change the values contained in the RichTextTables. The routine builds these Tables based on the values it fines in views that are defined in the rebuild routine. When this button is used and changes are made, I am refreshing the views that are affected using the NotesView.Refresh routine, then I'm rebuilding the tablses, closing the UI and reopening the UI to display the Tables. Well, this is not working as the changes do not display. In fact, if I close the document and reopen it, the changes still do not display. If I go to the view that was changed and open it in the UI and then go back an open the document, it displays the changes the second time I open it. How do I get this to work without having to open the view in the ui?

Anybody have any suggestions?

MJ

3

3 Answers

0
votes

First of all: Without seeing your code it is nearly impossible to help.

I try nevertheless: NotesRichtextitems need to be saved before they can be displayed in frontend. So you need to have a "CloseAndReopen" - Function, that does your updates, saves the backend- document and then reopens the document. Something like this:

'Declare variables
Dim ses As New NotesSession
Dim db As NotesDatabase

Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim body As NotesRichtextitem
Dim strUnid As String

'- Set database to get the document
Set db = ses.CurrentDatabase

'- get the current uidoc
Set uidoc = ws.CurrentDocument

'-save it, otherwise you will not be able to access the richtextitem
If uidoc.IsNewDoc Then Call uidoc.Save()

'- Get The backend document
Set doc = uidoc.Document

'- Get the richtextitem
Set body = doc.GetFirstItem( "Body" )

'- and do something with it
Call body.AppendText( "some very interesting text" )
Call body.AddNewline( 2 )

'- found this useful to make the Richtextitem have the changes directly
Call body.Compact()

'- Save it
Call doc.Save( True, True, True )

'- get the unid to be able to reopen
strUnid = doc.UniversalID

'- Make the "do you want to save" disappear
Call uidoc.Document.ReplaceItemValue( "SaveOptions" , "0" )

'- close it
Call uidoc.Close

'- Destroy the object for the doc (otherwise it might NOT really close)
Delete Doc

'- get it back
Set doc = db.GetDocumentByUNID( strUnid )

'- and reopen
Call ws.EditDocument( False , doc )

For your View- question: NotesView.Refresh does NOT Rebuild the index for the view. It just refreshes your In- Memory- representation with everything that happened since you initialized the object. But probably a "NotesView.AutoUpdate=True" might help. But probably your Server is simply to busy to keep the view index up to date, or the view is not configured to automatically update (check the view properties)...

Again: Without code, this is just blind guessing...

0
votes

This is very common since R4 (this versions introduced LS): RT updates are reflected only after closing and opening document again. If you alter RT in open document, you need to reopen it.

Simple solution is to use:

unid = ... ' get UNID of current document
workspace.CurrentDocument.Close
workspace.EditDocument unid, False

This will reopen document and you will see changes to RT.

0
votes

Your document should be saved. And your RichtextItem should be updated. After that only the content of the RichText item will be shown.

  • Set the SaveOptions field as 0. Save the document.
  • Update the RichText field.