Subject: No error, but no data either !!
Thanks…BUT
The field ‘CalendarDateTime’ is found in ‘doc’ as I have printed some text to the log if doc2 hasitem.
But after the agent runs, the field in doc2 contains no data??
Any other ideas
Complete code below
Sub Initialize
On Error Goto errhandler
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim doc1 As NotesDocument
Dim doc2 As NotesDocument
Dim agent As NotesAgent
Dim item As NotesItem
Dim nab As NotesDatabase
Dim view As NotesView
Set agent = session.CurrentAgent
Set db = session.CurrentDatabase
'Get document used for passing data
Print "Oil Secretaries Calendar Agent Running Activated"
Print "Attempting to Locate Calendar Entry being Saved..."
Set doc = db.GetDocumentByID(agent.ParameterDocID)
If doc.HasItem("Form") Then
Print "Calendar Entry Found"
Else
Print "Calendar Entry NOT found"
End If
'Run Loop through any names in AlarmDialog Field
Forall n In doc.AlarmDialog
'Get current NAB
Set nab = session.GetDatabase("" , "names.nsf")
'Get view in NAB
Set view = nab.GetView("($Users)")
'Find person document in view
Print "Attempting to Locate Person Document in NAB..."
Set doc1 = view.GetDocumentByKey( n, True)
If doc1.HasItem("mailserver") Then
Print "Person Document Found"
Else
Print "Person Document NOT found"
End If
'Find MailServer field values from Person document
Print "Extracting MailServer from Person Document"
Dim homeserver As New NotesName ( doc1.GetItemValue("mailserver")(0))
Dim Servername As String
servername = homeserver.Common
Print "ServerName" & servername
'Find Mailfile field values from Person document
Print "Extracting Mailfile path from Person Document"
mailfile = doc1.GetItemValue("mailfile")
Print "Persons Mailfile Path is " & mailfile(0)
'Get database to create document in
Dim destdb As New NotesDatabase( "" , mailfile(0))
'Create mini-doc
Set doc2 = New NotesDocument(destdb)
Set item = doc.GetFirstItem("$Alarm")
Call item.CopyItemToDocument(doc2, "$Alarm")
Set item = doc.GetFirstItem("$AlarmOffset")
Call item.CopyItemToDocument(doc2, "$AlarmOffset")
Set item = doc.GetFirstItem("Subject")
Call item.CopyItemToDocument(doc2, "Subject")
If doc.HasItem("RepeatDates") Then
Print "Repeat Dates Found"
Else
Print "CalendarDateTime Found"
End If
doc2.CalendarDateTime=doc.GetItemValue("CalendarDateTime")(0)
'Save and move mini-doc to folder
Call doc2.Save(True , False , True)
Call doc2.PutInFolder ("($Alarms)")
End Forall
ErrHandler:
Print "Got Error " & Cstr( Err() ) & " " & Error() & " in line: " & Cstr( Erl() )
Exit Sub
End Sub