Notes Ninjas Notes Ninjas
Lotus Notes hints, tips, error messages
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://www.notesninjas.com/#ChangeChildren or http://www.notesninjas.com/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

 

 

 Jump to:     Notes Tips
    Lotus Notes Index 
  Register for Tips
Previous Lotus Notes Tip 
    Next Lotus Notes Tip
Your company logo here?
Adam Foster
Free Cash Making Web Site
Free Revenue Earning Blog Site
 Free Revenue Earning Newsletter Site   
Free Search Pages Free Web stats
Free Contact Us page
Cheap .com domain names
 Need a website or 
   Lotus Notes
  problem solved?
Adam Foster
Lotus Notes 5 All-in-one Certification Exam Guide by Libby Schwarz, Ben Malekzadeh
Sort out your CLP with this book.
See at: Amazon.co.uk | Amazon.com |