Agent to refresh documents

Hello,

I have around 30 databases and there is view vXYZ in each database.

Normally in each database I select all the doucments in the view and run the refreshAgent on selected documents.

refreshAgent contains

@Command([ToolsRefreshSelectedDocs]);@All;@All

Could some one help me in providing the code where I provide the database names in the string

array and the agent refresh all the documents which are in view vXYZ (in all database)

Thanks

Regards

Pradeep

Subject: agent to refresh documents

dim s as new notessessionDim db As NotesDatabase

dim vw as notesview

dim lCnt as long

const SERVER as string= “- ur server name -”

dim vList(0 to 5) as string

vList(0)=“- ur database path -”

vList(1)=“- ur database path -”

vList(2)=“- ur database path -”

vList(3)=“- ur database path -”

vList(4)=“- ur database path -”

vList(5)=“- ur database path -”

for lCnt=lbound(vList) to ubound(vList)

set db=s.GetDatabase(SERVER,vList(lCnt))

if db.IsOpen then

	set vw=db.getview("vXYZ")

	vw.refresh

end if

next

set s=nothing

=====================================

or (take note, the code below might be slower coz it will traverse all db in ur server)

=====================================

dim s as new notessession

Dim dbdir As New NotesDbDirectory(s.CurrentDatabase.Server)

Dim db As NotesDatabase

dim vw as notesview

Set db = dbdir.GetFirstDatabase(DATABASE)

do While Not(db Is Nothing)

set vw=db.getview("vXYZ")

if not vw is nothing then

	vw.refresh

end if

loop

set dbdir =nothing

set s=nothing

Subject: RE: agent to refresh documents

Thanks for the response. but this code is for refreshing the view. ( not for the document refresh )I want to refresh the each document contents which are in the view.

I mean to say that if there are some docuemtns associated with mXYZForm in the databasae then how to refresh it or recalculate it ???

Manually I was running the agent in the vXYZ view which contains the mXYZ form in the selection formula . the agent @Command([ToolsRefreshSelectedDocs]);@All;@All )refresh all the documents in that view. but how to automate it on all database ?

Subject: RE: agent to refresh documents

finally I managed to write the code.

Sub Initialize

Dim s As New notessession

Dim db As NotesDatabase

Dim view As NotesView

Dim currDoc As NotesDocument

Dim nextDoc As NotesDocument

Dim i As Integer

Dim errormsg As String

On Error Goto LOGERROR



Dim lCnt As Long

Dim SERVER As String

Dim vList(0 To 60) As String

SERVER= ""

vList(0)="xyz1.nsf"	vList(1)="xyz2.nsf"



For lCnt=Lbound(vList) To Ubound(vList)

	

	Set db=s.GetDatabase(SERVER,vList(lCnt))

	

	If db.IsOpen Then

		

		Set view = db.GetView("vCloneFolderDoc")

		

		If Not view Is Nothing Then				

			Set currDoc = view.GetFirstDocument

			i=1

			

			While Not(currDoc Is Nothing)

				

				Set nextDoc = view.GetNextDocument(currDoc)

				currDoc.ComputeWithForm False,False

				currDoc.Save True,False

				Set currDoc = nextDoc

				Set nextDoc = Nothing

				i=i+1

				

			Wend				

			

			Print "Agent Logging: " + Cstr(i) + " documents have been updated on " + vList( lCnt) +"<br>"

		End If

		

		

	End If

Next





Exit Sub

LOGERROR:

errormsg = " ** Agent Error: " & Err & " - " & Error() & " in " & "Robot-RefreshAllDocs at " & Erl()

Msgbox errormsg

Resume Next

End Sub

and it works fine.

thanks a lot

Cheers

Mitwaa World