Manage Learn to apply best practices and optimize your operations.

Find All Children From Within A Subform

I had to link a Parent document to all its children and all links must be saved
in the same RichText Field with the children title (as if I should create a
table of context). The parent and the children was a subforms (that's because I
had a subform for Notes user and one for Web user). I found this way (maybe not
the best way...):

1. Do have in the Parent Subform a field RichtText called 'Sommario'
2. Create a hidden view with alias 'TD' with first column sorted ascending
containing this formula: @Text(@DocumentUniqueID) and with the view option
'Show response documents in a hierarchy' checked; for the view formula use:
SELECT ((form="ParentSubForm name") | @AllDescendants )
3. Create a field called 'titoloParagrafo' in the response subform in order to
contains the title of the child (compiled by the user)
4. In the parent subform create an Action LotusScript with this code: (look at
'Code' section)


It is a dynamic Action because if you create a child after you just compiled
the 'Sommario' field, the Action will 'zap' it and re-create the link for all
children found.
Sub Click(Source As Button)
Dim ws As New NotesUIWorkspace
Dim session As New notesSession
Dim db As NotesDatabase
Dim Doc As NotesDocument
Dim figlioDoc As notesDocument
Dim docUI As NotesUIDocument
Dim Sommario As NotesRichTextItem
Dim vista As Notesview

Set db=session.currentdatabase
Set docUI=ws.currentdocument
Set Doc=docUI.Document
Set vista=db.GetView("TD")

' really I don't know why, but if you omit the following While-Wend cicle
the script does not work - it does not read the view in the right way -
Set docA=vista.GetFirstDocument
While Not docA Is Nothing
Set docA=vista.GetNextDocument(docA)
Wend

Set Sommario=Doc.GetFirstitem("Sommario")
Set Sommario = Doc.ReplaceItemValue( "Sommario", "" )
Set figlioDoc = vista.GetChild( Doc )

' find all children
While Not ( figlioDoc Is Nothing )
Call Sommario.AddNewLine(1)
Call Sommario.Appenddoclink(figlioDoc, "Link" )
' here we take the child's title
titolo$=figlioDoc.titoloParagrafo(0)
Call Sommario.AppendText(titolo$)
Set figlioDoc = vista.GetNextSibling( figlioDoc )
Wend


Call Doc.Save( True, False )

End Sub

Dig Deeper on Lotus Notes Domino Administration Tools

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