< Back

Document Subject: Change a field's value on all children documents
Hint Short Cut: Add this to your code & documentation to help you find this page.
http://#ChangeChildren or http://A555F9/nn.nsf/ByAlias/ChangeChildren

A colleague wanted to change the name of all children documents to the new name of the patriach (top level) document. Here is the code.




Stick this in a button or the querysave event

Sub Initialize

 ' See http://www.notesninjas.com/#ChangeChildren
Dim uiw As New notesuiworkspace
Dim uidoc As notesuidocument
Set uidco = uiw.currentdocument
Dim doc As notesdocument
Set doc = uidoc.document
Call changeName(doc, "Rena")
End Sub

Add this as a function. It needs to be a funtion as it is recursively called.

Function changeName(d  As notesdocument, n As String) As Integer

 ' See http://www.notesninjas.com/#ChangeChildren
if d.Name(0) <> n then

   d.Name=n
  Call d.save(True,True)

 end if
Dim child As notesdocument
Dim chcol As notesdocumentcollection
Set chcol= doc.responses
Set child =chcol.getfirstdocument
Do Until child Is Nothing
 Call changeName(child, n)
 Set child =chcol.getnextdocument(child)
Loop
End Function