Manage Learn to apply best practices and optimize your operations.

Add Doclinks In A Main Document To All Child Documents

Ever needed to add doclinks in a main document to all child documents that
exist for it? This following piece of code will do just that. It runs in the
QueryClose event of the main document, and assumes that you have a view in the
database that lists all response documents, and consists of two columns: The
doc ID of the parent (sorted, formula of @Text($REF)), and the doc ID of the
response (formula of @Text(@DocumentUniqueID)).

When the main document is closed, the Rich Text field that contains the
doclinks to the response documents is rebuilt with doclinks to all the response
documents that currently exist.

Sub Queryclose(Source As Notesuidocument, Continue As Variant)

'This code will build the doclinks on the parent document to all the
response documents

'Define all the session, database, document, and view information
Dim ws As New NotesUIWorkspace
Dim session As New NotesSession
Dim db As NotesDatabase
Dim accesslevel As Integer
Dim view01 As NotesView
Dim doc As NotesDocument
Dim backendDoc As NotesDocument
Dim dc01 As NotesDocumentCollection
Dim rtitem As Variant
Dim richStyle As NotesRichTextStyle

'Set the database to be the one for the current session
Set db = session.CurrentDatabase

'If the access level of the user is reader, bypass the rest as they can
not update the doclink information anyway
accesslevel = db.CurrentAccessLevel
If accesslevel = ACLLEVEL_READER Then Exit Sub

'Set the view that shows all responses by a key of parent ID and form name
Set view01 = db.GetView("vuwHiddenAllResponses")

'Set the backend document for updating
Set backendDoc = Source.Document

'Gather a collection of all response documents that match the parent ID,
'define a rich text item to build the doclinks, and then loop through the
document collection (if any) to create all the doclinks.

'Build doclinks of Task documents
Set dc01 = view01.GetAllDocumentsByKey(Source.Document.UniversalID, True)
Set rtitem = New NotesRichTextItem (backendDoc,
"ProjectWorkDetailLinks")
Set richStyle = session.CreateRichTextStyle
richStyle.NotesFont = FONT_HELV
richStyle.FontSize = 8
richStyle.NotesColor = COLOR_DARK_CYAN
richStyle.Bold = True
Call rtitem.AppendStyle(richStyle)
Set doc = dc01.GetFirstDocument
Do Until doc Is Nothing
Call rtitem.AppendDocLink( doc , "" )
Call rtitem.AddTab( 1 )
Call rtitem.AppendText( Format$(doc.WorkDetailDate(0),"mm/dd/yy") + "
- " + doc.WorkDetailCommonName(0) + " - " + doc.WorkDetailAbstract(0))
Call rtitem.AddNewLine(1)
Set doc = dc01.GetNextDocument(doc)
Loop

Call backendDoc.Save(True, False)

End Sub

Dig Deeper on Domino Resources - Part 2

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close