View not refreshing?

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

Subject: View not refreshing?

Seems like the server has no access to the documents in the view. Are there any reader fields?

Subject: RE: View not refreshing?

No, there are no reader fields on the form. The server does have Server - Manager access to the database.

Subject: RE: View not refreshing?

I ran the agent again - set it to run at 12:45 and it says it ran, but the view is empty. I just re-ran it manually - by selecting Actions - Run and it rebuilt the view. Does this have anything to do with me removing all docs? Why does it work when manual, but not automatic?

Subject: View not refreshing?

I added Call idview.Refresh to the bottom and that didn’t work.

Subject: View not refreshing - with scheduled agent?

Subject: View not refreshing?

I am a little surprised that no one has suggested anything nor asked any questions. Anyway …

You have not yet told us anything about the view or about what debugging steps you have done to verify whether or not the agent is working or how far it is working. My first guess is that the agent may work. According to the code, it deletes all the docs in one view then creates a bunch of new docs using a SQL source. I am guessing that the new docs are created, but they are not in whatever view you are looking in. What is the selection formula for the view?

Before you start posting long questions, you would be better off doing some debugging. Add some PRINT or MSGBOX statements so you can confirm how far it succeeds. Do you know whether it is successfully reading the SQL source? How many records? Is it creating any docs? How many?