devguru001
asked on
NotesRichTextNavigators, NotesRichTextRanges and NotesRichTextSections
Hi,
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.
Code:
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(RTE LEM_TYPE_S ECTION) Then
Count = 0
Set rts = rtNav.GetFirstElement(RTEL EM_TYPE_SE CTION)
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(RTELE M_TYPE_SEC TION, count) Then
Messagebox(rts.Title)
Call RTNav.SetPositionAtEnd(RTN av)
Call rtrange.SetBegin(rtnav)
Call rtrange.Remove
Set RTS = Nothing
End If
Else
Set rts = rtNav.GetNextElement(RTELE M_TYPE_SEC TION)
End If
Wend
End If
Call doc.Save(True, True)
End Sub
Memo.png
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 "-------------------------
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.
Code:
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 = "-------------------------
If rtnav.FindFirstElement(RTE
Count = 0
Set rts = rtNav.GetFirstElement(RTEL
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(RTELE
Messagebox(rts.Title)
Call RTNav.SetPositionAtEnd(RTN
Call rtrange.SetBegin(rtnav)
Call rtrange.Remove
Set RTS = Nothing
End If
Else
Set rts = rtNav.GetNextElement(RTELE
End If
Wend
End If
Call doc.Save(True, True)
End Sub
Memo.png
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.
ASKER
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you are trying to remove just the section, why not use the remove method for a section.
rts.remove
If you want to delete the section and everything below it, you have removed everything below it. Then call the remove method.
rts.remove
If you want to delete the section and everything below it, you have removed everything below it. Then call the remove method.
ASKER
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 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.
ASKER
I only noticed after I found my solution that the last question he asked was what I did.
So why not an "A" ? ;-)