In TeamRoom, if a user enters an event, and then renames the event after entering Team Documents under it, the event titles will not match. This code will find all the Team Documents and change the event titles.
Add a computed for display field called "OLD_EventSummary" to the Event form with that computes to this value:
@If(@IsDocBeingLoaded; EventSummary; OLD_EventSummary)
Add this code to the Event form QuerySave:
Sub Querysave(Source As Notesuidocument, Continue As Variant)
Const fieldRename = "EventTitle"
Const fieldID = "OLD_EventSummary"
Const fieldNewValue = "EventSummary"
If Not Source.IsNewDoc And (Source.FieldGetText(fieldID) <> Source.FieldGetText(fieldNewValue)) Then
Call RenameRelated(fieldRename, fieldID, fieldNewValue)
End If
End Sub
Add this function to the Event form QuerySave:
Sub RenameRelated(renameField As String, IDfield As String, newValueField As String)
'Timothy Roloff, 7/8/04
'If EventSummary has changed, find all child Documents, and change their EventTitles
On Error Goto RenameRelatedAbort
Dim ns As New NotesSession
Dim ws As New NotesUIWorkspace
Dim db As NotesDatabase
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim IDvalue As String
Dim newValue As String
Dim search As String
Dim coll As NotesDocumentCollection
Set db = ns.CurrentDatabase
Set uidoc = ws.CurrentDocument
Dim intMod As Integer 'Number of documents modified by this function
Dim unused As Variant
Dim j As Integer
IDvalue = uidoc.document.GetItemValue(IDfield)(0)
newValue = uidoc.document.GetItemValue(newValueField)(0)
search = renameField & "=" & """" & IDvalue & """"
Set coll = db.Search(search,Nothing,0)
intMod = 0
For j = 1 To coll.Count
Set doc = coll.GetNthDocument(j)
If Not (doc.GetItemValue(renameField)(0) = newvalue) Then
Call doc.ReplaceItemValue(renameField, newvalue)
Call doc.Save(True, True)
intMod = intMod + 1
End If
Next
Print Cstr(intMod) & " documents modified (" & renameField & "=" & """" & IDvalue & """" & ")"
Call uidoc.Close
Exit Sub
RenameRelatedAbort:
unused = Messagebox("Action aborted", 0, "No documents have been modified")
End Sub