I am trying to loop through the documents in a view to re-save them as they are not being categorised on a field that has a value! - I have tried an @Command([FileSave]) on an individual document and it categorises it.
I then coded this :
Sub Initialize
Dim s As New NotesSession
Dim doc As NotesDocument
Dim v As NotesView
Dim db As NotesDatabase
Set db = s.CurrentDatabase
Set v = db.GetView("PeopleToBeUpdated")
Set doc = v.GetFirstDocument
Do While IsDocThere(doc)
Call doc.Save(True,True,True)
Set doc = v.GetNextDocument(doc)
Loop
End Sub
This runs through all the documents, but they are still not categorised.
Can anyone offer any suggestions as to why? Or what to do?
A few things - first I would be fixing the reason why you need to be running this code in the first place!
You field must have a problem - or the view that you are categorizing with.
Second with LS you need to be refreshing the document before saving it - otherwise you are doing nothing. Put a doc.computewithform(false,false) before the save
Third - I don’t know how you have setup your view for this code but the document may disappear from you when it is saved (if it is dependant on the field you are updating). So you need a loop strategy like the following if this is the case:
I had the same problem where i didn’t see values allthough they where there.
found this code that runs in an agent on selected form:
Sub Initialize
'Dim w As New notesuiworkspace
Dim col As notesdocumentcollection
Dim midoc As notesdocument
Dim s As New notessession
Dim db As notesdatabase
Dim item As NotesItem
Set db=s.currentDatabase
Set col=db.unprocessedDocuments
Set midoc=col.getFirstDocument
Do While Not midoc Is Nothing
If midoc.combined(0) = "Combined" Then
Set midoc=col.getNextDocument(midoc)
Else
Call midoc.ComputeWithForm(True,False)
Set item = midoc.ReplaceItemValue( "combined", "Combined" )
Call midoc.save(True,False)
Set midoc=col.getNextDocument(midoc)
End If
Loop
End Sub
note that this agent will fail when there are more then 3000 docs to be processed. Dunno why…
Check the Advanced Tab(Last tab) of the column properties, for the “Programatic Use Name” of the field. Make sure it is the same as your mapping field name. If it is calculated one, make sure this column has a unique number when compared to other columns of the view.