RTF-list of doc ids for all doclinks

I am sure this may be pretty easy, but having not programed in a while, I am drawing a blank. The below script navigates a RTF and returns the document ids of each doclink found. All I need is to create a list of the document ids for all of the doclinks found in the RTF. The code gets the ids, however, I am drawing a blank as to how to create the list.

Dim session As NotesSession

Dim db As NotesDatabase

Dim dc As NotesDocumentCollection

Dim doc As NotesDocument

Dim rti As NotesRichTextItem

Dim rtnav As NotesRichTextNavigator

Dim rtlink As NotesRichTextDocLink

Dim Item As NotesItem

Dim Item2 As NotesItem

Dim UNID As Variant





Set session = New NotesSession

Set db = session.CurrentDatabase

Set dc = db.UnprocessedDocuments

Set doc = dc.GetFirstDocument

Set rti = doc.GetFirstItem("CaseComments")

Set rtnav = rti.CreateNavigator

Set rtlink = rtnav.GetFirstElement(RTELEM_TYPE_DOCLINK)

If rtlink Is Nothing Then

	Set item = doc.ReplaceItemValue( "DocLinkIDs","No doclinks in Case Comments Field" )

	Call doc.Save(True,True)

	Exit Sub

End If



While Not(rtlink Is Nothing)

	UNID = rtlink.DocUnID

	Set Item2 = doc.AppendItemValue("DocLinkIDs",UNID)

	Set rtlink = rtnav.GetNextElement

Wend

Call doc.Save(True,True)

THANKS!

Subject: RTF-list of doc ids for all doclinks

Here what you do:

//create an array

Dim db As NotesDatabase

Dim dc As NotesDocumentCollection

Dim doc As NotesDocument

Dim rti As NotesRichTextItem

Dim rtnav As NotesRichTextNavigator

Dim rtlink As NotesRichTextDocLink

Dim Item As NotesItem

Dim Item2 As NotesItem

Dim UNID As Variant

dim docIds() as string

dim index as integer

Set session = New NotesSession

Set db = session.CurrentDatabase

Set dc = db.UnprocessedDocuments

Set doc = dc.GetFirstDocument

Set rti = doc.GetFirstItem(“CaseComments”)

Set rtnav = rti.CreateNavigator

Set rtlink = rtnav.GetFirstElement(RTELEM_TYPE_DOCLINK)

If rtlink Is Nothing Then

Set item = doc.ReplaceItemValue( “DocLinkIDs”,“No doclinks in Case Comments Field” )

Call doc.Save(True,True)

Exit Sub

End If

index = 0

redim docIds(index)

While Not(rtlink Is Nothing)

'Make sure these are the same field types

docIds(index) = rtlink.DocUnID

Set Item2 = doc.AppendItemValue(“DocLinkIDs”,docIds(index))

Set rtlink = rtnav.GetNextElement

index = index + 1;

ReDim Preserve docIds(index)

Wend

Call doc.Save(True,True)

Subject: Solution-Thanks To You Both for Responding!

To make this work, I created an array. I made a slight change in the code as follows:

Changed>>Set Item2 = doc.AppendItemValue(“DocLinkIDs”,docIds(index))

To>>Set Item2 = doc.ReplaceItemValue(“DocLinkIDs”,docIds)

Subject: Try…

FirstTime = True	While Not(rtlink Is Nothing)

	UNID = rtlink.DocUnID

	If FirstTime Then

		Set Item2 = doc.ReplaceItemValue("DocLinkIDs",UNID)

		FirstTime = Ffalse

	Else

		Call Item2.AppendToTextList(UNID)

	End If

	Set rtlink = rtnav.GetNextElement

Wend