earlier on i posted a question on composing documents in huge amount and display it on a view.
My program goes as follows:
while j<> somevalue
set docFromView = workView.getFirstDocument
while not docFromView is Nothing
...............some actions..quite abit of if else...............
Wend
save doc
wend
ok now the situation is i will press the action button to start reading all items from a view and then compose them into a individual documents. Lets say there are 1,122 different items in the view, then i would have 1,122 different new documents to be composed.
The final problem is the moment action button is pressed, it physically HANG…any suggestions?
Dim db As notesdatabase
Dim view As notesview
Dim collection As notesdocumentcollection
Set db = session.currentdatabase
Dim docA As notesdocument
Set view = db.getview("view name goes here")
Set collection = db.unprocesseddocuments
Set docA = collection.getfirstdocument
While Not docA Is Nothing
Dim docB As New notesdocument(db)
Dim a As String
Dim b As String
Dim h As String
a = docA.Name(0)
b = docA.Location(0)
h = docA.Dept(0)
docB.Form = "your form name goes here"
docB.Name = a
docB.Location = b
docB.Dept = h
Call docB.save (True, True)
Set docA = collection.getnextdocument (docA)
Wend
Are you asking why it’s hanging? If so, I’d do two things:
Put a print statement in so that every 10 or 100 documents or so it prints out the Date/Time and the doc number. That way, even if it looks like it’s hung, you’ll see the print statements on your status bar.
If it’s really and truly hanging, you should use the debugger and step through (just put a breakpoint at the bottom of each loop. Perhaps you are failing to increment j? Perhaps j never is equal to somevalue? Perhaps you’re not advancing in the view and so docFromView is always something?
initially i find out how many different items there are in a specific view using a counter, which then gives me the value of 1,122 so i believe the value is correct. Next i also did print the value of j, it turns out that the counter count up to 118++ and then enter the “hanging” mode.
Up till now i still cannot understand why. As for the debugger, i rather give it a miss, coz if i reali go for debugger den i would have to click 1230 times!!! >.<
Besides, i did try using counter starting from 1 to 40 , 1 to 50, 1 to 70, 1 to 90 and 1 to 100. All works fine…except when 1 to 120 den problem arise.
Only a snippet of your code is shown above, but the
“while not docFromView is Nothing” loop appears to run forever unless you’ve omitted a
set docFromView = workView.getNextDocument(docFromView)
Even if this is set, you have to ensure that the documents being created do NOT show up in this view as the you’ll get another infinite loop as you’ll create new documents based on documents you just created etc.
If the documents will normally turn up in the view, then set the view update off.
I did the " set docFromView = workView.getNextDocument(docFromView)" so it shldnt be that error.
As for update, when i tried using counter from 1 to 100, i found out that the view isnt autoupdating, i still need to press F9 for the view to refresh.
The AutoUpdate is for the backend view indexing, not the displayed uiview.
If the new documents being created are included in the select statement of the view, then these will be part of the view when the view index is refreshed.
To verify this, put a check in your code to count the documents and end the loop if the count exceeds your initial count.
initCount = view.EntryCount
count = 0
.
.
… in loop
count = count + 1
if count > initCount then
MsgBox “Got too many! I’d better turn off AutoUpdate”