Doc.Save in lotusscript works in rel 7 but not in rel 8

In a LN database there is a form with many computed fields with lookups and other formulas. I made a script which updates one or more marked documents; that is, each marked document gets formulas updated and then is saved.

This has worked fine for about five years, but when users updated clients from release 7 to release 8.5.2 it does no longer work. Here’s the code:

Dim session As New NotesSession

Dim db As NotesDatabase

Dim dc As NotesDocumentCollection

Dim doc As NotesDocument



Dim usersaid As String

Dim flag As Variant



Set db = session.CurrentDatabase

Set dc = db.UnprocessedDocuments



If (Not dc Is Nothing) Then

	

	'Present user with number of found marked documents, and ask for proceed

	usersaid = Msgbox("Found " + Cstr(dc.Count) + " marked documents."  + Chr(13) + Chr(13) +_

	"Do you want all formulas in those documents recalculated?", 36, "Updating documents")

	

	'Update if user clicked Yes

	If usersaid = "6" Then

		

		For i = 1 To dc.Count

			Print "Updating " + Cstr(i) + " of " + Cstr(dc.Count)	

			Set doc = dc.GetNthDocument(i)

			

			'Use this method to update doc's all formulas in backend

			flag = doc.ComputeWithForm(True, False)

			'MsgBox "Calc: " + CStr(flag)

			

			flag = doc.Save(True, True)

			'MsgBox "Save: " + CStr(flag)

		Next

		

	End If

	

End If



Print ""

To see what happens, I uncomment the Msgbox lines. In LN 7, it returns True on both lines. In LN 8 in returns True after doc.ComputeWithForm, but returns 0 after doc.Save. The documents are not updated.

The strangest thing is, if I switch the LS debugger on, and click Step into through the script, it works in LN 8 also! Then the second Msgbox line returns -1, and the documents are updated and saved properly.

I tried to re-write this same code manually (no copy!) in a new sub in LN 8.5.2 designer, but the problem is still there.

Any ideas would be much appreciated.

Subject: known issue, see here

http://www-01.ibm.com/support/docview.wss?uid=swg1LO55409

Subject: Your advice fixed it!

I tested to insert the suggested

Print doc.Universalid

on the line before doc.ComputeWithForm, and then my agent worked as it should again. It also works when I let it print the content of a field from doc, that is, makes a read operation on doc.

Thanks a lot, Paul!! This was really helpful!