
OpenNTF Code Bin
About This Code
Brief Description:
Update TeamRoom "Team Doc" Event Titles on Event Summary change
Contributor:
Timothy Roloff
Last Modified:
08 Jul 2004
OpenNTF Disclaimer
All of the program code and information presented in the OpenNTF.org Code Bin are provided "as-is", and should be used at your own risk. OpenNTF.org make no express or implied warranty about anything in the Code Bin, and OpenNTF.org will not be responsible or liable for any damage caused by the use or misuse of anything from this site. OpenNTF.org makes no guarantees about anything. Please thoroughly test all of the knowledge and code you find here before you attempt to use them in your production environment.
Code / Description
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
Usage / Example
Comments
Posted by K Katero on 09/14/2004 08:01:15 PMSuper Job !!! Thank you for submitting this code..
This really saved me from have to modify hundreds of documents all the time. I don't know anything about lotusscript and your code was very easy to implement and worked perfectly. Thank you!! Thank you!!
Posted by K Katero on 09/14/2004 08:08:40 PMDevelperWorks
I forgot to mention, I found this site from a post just added to DeveloperWorks today announcing OpenNTF.org. Thanks for the post, I really like your site, Great!!