I have the following code in an agent that runs daily. The agent log says it runs, however the view is blank. When I run it manually, it works. Any idea why my view isn’t being refreshed after the agent runs automatically as scheduled?
Options:
Option Public
Option Declare
Uselsx “*LSXODBC”
Initialize:
'Load Staff Table (active only) from ACS warehouse
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase, codedb As NotesDatabase
Dim con As ODBCConnection
Dim qry As ODBCQuery
Dim res As ODBCResultSet
Dim idView As NotesView, codeview As NotesView
Dim doc As NotesDocument, iddoc As NotesDocument
Dim max As Double, id As String
Dim i As Double, j As Double
Dim bigArray() As String
Dim answer As Variant
Dim newone As String
Dim vc As NotesViewEntryCollection
Set db = session.CurrentDatabase
Set idView=db.getView("DSP_STAFF_EntID")
Set vc =idview.AllEntries
Call vc.RemoveAll(True)
’ warehouse control
Dim wh_db As New NotesDatabase("","")
Dim wh_doc As NotesDocument
Dim wh_view As notesview
Set wh_db=session.getdatabase("DDAS2/Notes","warehousctacs.nsf")
Set wh_view=wh_db.getview("CT1")
Dim c1 As String, c2 As String, c3 As String, c4 As String
Set wh_doc = wh_view.Getfirstdocument
If Not wh_Doc Is Nothing Then
c1 = wh_doc.ColumnValues(0)
c2 = wh_doc.ColumnValues(1)
c3 = wh_doc.ColumnValues(2)
c4 = wh_doc.ColumnValues(3)
End If
Set con = New ODBCConnection
Set qry = New ODBCQuery
Set res = New ODBCResultSet
Call con.connectTo(c1,c2,c3,c4)
Set qry.Connection = con
'Get Codes
qry.SQL = "select * from staff where active_ind = 'Y'"
Set res.Query = qry
res.Execute
res.LastRow
max = res.NumRows
For j = 1 To max
Set doc = db.CreateDocument
doc.Form = "STAFF"
res.CurrentRow = j
doc.entityID = res.GetValue("id_number")
doc.FullName = res.GetValue("Name")
doc.LName = res.GetValue("sort")
doc.office_code = res.GetValue("Office_Code")
doc.staff_type_code = res.GetValue("staff_type_code")
doc.staff_email = res.GetValue("email_address")
Call doc.Save(False,False)
Next
res.Close(DB_CLOSE)
End Sub