Link to home
Create AccountLog in
Avatar of devguru001
devguru001Flag for South Africa

asked on

NotesRichTextNavigators, NotesRichTextRanges and NotesRichTextSections


So I have an interesting problem. Here is the scenario. We have a helpdesk db where sometimes it's required to contact the user, keeping them up to date or whatever the reason may be. So from the helpdesk I would create a new memo. This memo would contain whatever you want to ask or tell the user and at the end of the email there is a section called "---------------------------------------------------------------------------------------History---------------------------------------------------------------------------------------". This section contains all of the correspondence between the helpdesk and the user. The history is copied from a response document (called a summary document) connected to the specific helpdesk call that basically contains all of the correspondence. This history section is a section that contains other sections. See image below. So I need to, after the email has been sent, to delete the history section and add the current correspondence back into the helpdesk. Reason for deleting the history is because that history is stored in a summary document so we only need the latest correspondence.

Problem is when I want to navigate to the history section and setting the range and all and then delete everything from the history downward, Notes just doesn't delete the history section too. It deletes anything AFTER the history section but not the history section INCLUDED.

Here is some sample code that I was playing around with but no joy. Your assistance in this will be GREATLY appreciated.


Sub Click(Source As Button)
      Dim ws As New NotesUIWorkspace
      Dim uidoc As NotesUIDocument
      Dim doc As NotesDocument
      Dim rti As NotesRichTextItem
      Dim rtnav As NotesRichTextNavigator
      Dim rts As NotesRichTextSection
      Dim rtrangesec As NotesRichTextRange
      Dim rtt As NotesRichTextTable
      Dim count As Integer
      Dim strtitle As String
      Set uidoc = ws.CurrentDocument
      Set doc = uidoc.Document
      If uidoc.EditMode Then
            uidoc.EditMode = False
      End If
      Set rti = doc.GetFirstItem("Body")
      Set rtnav = rti.CreateNavigator
      strtitle = "---------------------------------------------------------------------------------------History---------------------------------------------------------------------------------------"
      If rtnav.FindFirstElement(RTELEM_TYPE_SECTION) Then
            Count = 0
            Set rts = rtNav.GetFirstElement(RTELEM_TYPE_SECTION)
            If RTS Is Nothing Then
                  Messagebox("Did not get first section")
            End If
            While Not  rts  Is Nothing            
                  Count = count + 1
                  If RTS.Title = STRTitle Then
                        Set rtrange = rti.CreateRange
                        If RTNav.FindNthElement(RTELEM_TYPE_SECTION, count) Then                        
                              Call RTNav.SetPositionAtEnd(RTNav)            
                              Call rtrange.SetBegin(rtnav)                        
                              Call rtrange.Remove                              
                              Set RTS = Nothing
                        End If
                        Set rts = rtNav.GetNextElement(RTELEM_TYPE_SECTION)            
                  End If
      End If
      Call doc.Save(True, True)

End Sub
Avatar of Sjef Bosman
Sjef Bosman
Flag of France image

Can you try to avoid messing with RT-fields? IMHO you should just store the history in a separate field. In a later stage, you can assemble whatever you want easily.
Avatar of devguru001


I did try storing it in another field but problem is the recipient doesn't then see it because they don't have that field on their memo form.
Avatar of Sjef Bosman
Sjef Bosman
Flag of France image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
If you are trying to remove just the section, why not use the remove method for a section.


If you want to delete the section and everything below it, you have removed everything below it. Then call the remove method.
Hi guys,

I have found a solution that alleviates the problem with working with the richtextnavigator so much. I compose the email in the helpdesk db, then when the helpdesk person clicks on Send Mail, the uidoc closes but I still have a handle on the notesdocument, I then add the email into my summry, I add the history at the end of the body field and send the mail. Problem solved. Thanks for the feedback. I think this was the best solution for me to follow.
I only noticed after I found my solution that the last question he asked was what I did.
So why not an "A" ?  ;-)