Hi ,Below is the code and getting erro at line no. 44 - that is ‘iLock = 0’
Option Public
Option Declare
Use “ExtendedFunctionality”
Use “Notification Class”
Sub Initialize
On Error Goto errorHandler
Const sAgentLogFile = "amatalog.nsf"
Dim nSession As New NotesSession
Dim nThisDb As NotesDatabase
Dim nView As NotesView
Dim nAgentLog As NotesLog
Dim nDoc As NotesDocument
Dim nLockDoc As NotesDocument
Dim nNotification As Notification
Dim nStartTime As New NotesDateTime ( "" )
Dim nEndTime As New NotesDateTime( "" )
Dim sAgentMessage As String
Dim iLock As Integer
Dim iCount As Integer
Dim iTime(0 To 4) As Long
Dim vData As Variant
Dim Op100updtFlag As String
Call nStartTime.SetNow
Set nThisDb = nSession.CurrentDatabase
'-- set agent title, use backslash to create categorization in agentlog file
Set nAgentlog = nSession.CreateLog( nThisDb.Title & "\" & nSession.CurrentAgent.Name )
Call nAgentlog.OpenNotesLog( nThisDb.Server, sAgentLogFile )
Set nProfileDoc = nThisDb.GetProfileDocument( "ProfileDocument" )
Set nLockDb = nSession.GetDatabase( nProfileDoc.LockServer(0), nProfileDoc.LockLocation(0) )
If Not nLockDb.IsOpen Then
sAgentMessage = "agent not successful, locking database not open."
Call nAgentlog.LogAction(sAgentMessage)
Call nAgentlog.Close
Exit Sub
End If
Set nView = nThisDb.GetView("Op100Notification")
Set nDoc = nView.GetFirstDocument
iCount = 0
iLock = 0
While Not (nDoc Is Nothing)
Op100updtFlag= nDoc.Op100UpdtFlag(0)
If Op100updtFlag="Y" Then
If LockDocument( nDoc, nLockDoc ) Then '-- document is locked '-- Sub in ExtendedFunctionality
Set nNotification = New Notification( "Send CaRM Due date Notification" )
Set nNotification.ParameterDoc = nDoc
vData=Evaluate( |@Unique(SAAttendee:SEAttendee)|, nDoc )
Call nNotification.SendTo( vData, "", "Q2B CaRM alert agent" )
iCount = iCount + 1
nDoc.Op100UpdtFlag=""
Call SaveLockDocument (nDoc, nLockDoc) '-- Sub in ExtendedFunctionality
Call nDoc.Save(True,True)
Call UnlockDocument (nDoc, nLockDoc, True) '-- Sub in ExtendedFunctionality
Else
iLock = iLock + 1
End If '-- doc is not locked
End If
Set nDoc = nView.GetNextDocument(nDoc)
Wend
'-- agentmessage when succesful
Call nEndTime.SetNow
iTime(0) = nEndTime.TimeDifference( nStartTime )
iTime(1) = Fix( iTime(0) / 3600 )
iTime(2) = Fix( (iTime(0) - 3600*iTime(1))/60 )
iTime(3) = Fix( (iTime(0) - 3600*iTime(1) - 60*iTime(2)))
If iCount>0 Or iLock>0Then
sAgentMessage = "agent successful, " & iCount & " mails send and " & iLock & " documents locked in " & Right("00" & iTime(1), 2) & ":" & Right("00" & iTime(2), 2) & ":" & Right("00" & iTime(3), 2) & " ."
Call nAgentlog.LogAction(sAgentMessage)
End If
Call nAgentlog.Close
Exit Sub
errorHandler:
If Err=4294 Then
'Unable to send mails because no name found in NAB. Hence resume next
Resume Next
End If
If Err=4295 Then
'Unable to send mails because Multiple names found in NAB. Hence resume next
Resume Next
End If
'-- agentmessage when an error has occured
sAgentMessage = Error$ & " on line: " & Str(Erl)
Call nAgentlog.LogError(Err, sAgentMessage)
'Call SendError( "Agent CaRM Op100 Update", nDoc )
Exit Sub
End Sub