Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

View and Agent trouble

Status
Not open for further replies.

kennethl

Programmer
Apr 8, 2004
4
GB
Hi,

I have a view and I want to save each of the documents in the view in order to update the fields using an agent and the following code:

Sub Initialize
' instantiate the notessession object
Dim s As New NotesSession

' declare object variables
Dim db As NotesDatabase
Dim v As NotesView
Dim doc As NotesDocument


' instantiate objects
Set db = s.CurrentDatabase
Set v = db.GetView("V_ENG")
Set doc = v.GetFirstDocument

Do Until doc Is Nothing

' save the doc
Call doc.Save( False, False )
Set doc = v.GetNextDocument(doc)
Loop

' refresh the view
Call v.Refresh

End Sub

I am really stuck on this so any help or advise would be greatly appreciated.

Kind regards,
Kenneth
 
What are you updating? I can only see a 'save', and the save itself will not do much...

If it is any computed values within the form(s) you want to recompute you can try the following:

Do Until doc Is Nothing
Call doc.ComputeWithForm(true, false)
' save the doc
Call doc.Save( True, False )
Set doc = v.GetNextDocument(doc)
Loop

Be aware that the .ComputeWithForm method is a little 'heavy', so the performance (runtime) will be longer, significantly longer if you have a LOT of documents.

If it is a specific value then add it in from 'somewhere':

Do Until doc Is Nothing
' doc.<Fieldname> = <some value> in e.g.
doc.UpdateDate = Now
' save the doc
Call doc.Save( True, False )
Set doc = v.GetNextDocument(doc)
Loop

The statement v.refresh will have no visible effect in the UIView, it only refreshes backend view, so without knowing exactly what the view does I would have dropped that line. Resource hungry, and I use it only when I need to do a second pass in the same view(s).




Brgds,

TrooDOS
 
TrooDos, thanks a million. Your suggestion worked :)

I wanted to recompute any computed values within the forms in the view so the code below worked perfectly for me:

Do Until doc Is Nothing
Call doc.ComputeWithForm(true, false)
' save the doc
Call doc.Save( True, False )
Set doc = v.GetNextDocument(doc)
Loop

Many thanks again for your prompt response.
Kind regards,
Kenneth


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top