Doc update via script breaks documents for normal use

I have an action button in a View that uses Lotusscript to modify fields in UIDocs like doc.Field1, doc.Field2 by going through a document collection until the fields in all selected doc have been updated.

This works fine and each document is updated with the new field values as they should.

Here is my problem. All documents that have been "touched/processed" by my script cannot be modified/saved anymore. I can open the modified documents, but when I enter new information in any of the document fields and use File - Save it does not complain but does not save the new info.

All other documents in the dB are fine - my script must do something to each processed document to cause this behavior. I am kind of stunned - some kind of lock, undefined state?

Any ideas how to make this right again would be appreciated. Code looks something like below -some items are commented out - duplicates at this point of troubleshooting. Did I get confused with the docs in the current collection vs the parent docs that holds the info???

It does update correctly but the file state is compromised somehow ...

Sub Click(Source As Button)
Dim session As New notessession
Dim db As notesdatabase
Dim view As notesview
Dim doc As notesdocument
Dim dc As notesdocumentcollection

Dim ws As New NotesUIWorkspace
Dim uiview As NotesUIView
Dim uidoc As NotesUIDocument
Dim rt As NotesRichTextItem
Dim InputForm As NotesDocument

Dim f As Integer
Dim count As Integer
Dim scount As String
Dim filename As String
Dim VesselNew As String
Dim VoyageNoNew As String
Dim DocumentCutOffnew As String
Dim DocumentCutOffTimenew As String
Dim FCLCutOffnew As String
Dim FCLCutOffTimenew As String
Dim ETDnew As String
Dim ETAnew As String
Dim flag As Boolean

'flag = ws.DialogBox( "Vessel_Voyage_update", True, True, , True, True, , "Update Dates for selected Documents", , , , True )
flag = True

VesselNew = Inputbox$ ("Please Enter new Vessel Name - or current Vessel if no Change needed:", "Vessel" , VesselNew , 30, 60)
VoyageNoNew = Inputbox$ ("Please Enter new Voyage Number - or current Voyage No. if no Change needed:", "VoyageNo" , VoyageNoNew , 30, 60)
DocumentCutOffnew = Inputbox$ ("Please Enter new Doc CutOff Date:", "DocumentCutOff" , DocumentCutOffnew , 30, 60)
DocCutOffTimenew = Inputbox$ ("Please Enter new Doc CutOff Time", "CutOffTime" , DocCutOffTimenew , 30, 60)
FCLCutOffnew = Inputbox$ ("Please Enter new FCL CutOff Date", "FCLCutOff" , FCLCutOffnew , 30, 60)
FCLCutOffTimenew = Inputbox$ ("Please Enter new FCL CutOff Time", "FCLCutOffTime" , FCLCutOffTimenew , 30, 60)
ETDnew = Inputbox$ ("Please Enter new ETD", "ETD" , ETDnew , 30, 60)
ETAnew = Inputbox$ ("Please Enter new ETA", "ETD" , ETAnew , 30, 60)


Set db=session.currentdatabase
Set uiview=ws.Currentview
Set dc=uiview.documents
Set doc=dc.Getfirstdocument

count=0
If flag = True Then
While Not (doc Is Nothing)
doc.Vessel = VesselNew
doc.VoyageNo = VoyageNoNew
doc.DocumentCutOff = DocumentCutOffnew
doc.DocCutOffTime = DocCutOffTimenew
doc.FCLCutOff = FCLCutOffnew
doc.FCLCutOffTime = FCLCutOffTimenew
doc.ETD = ETDnew
doc.ETA = ETAnew
doc.SaveOptions="0"
doc.Save True, False
count=count+1
Set doc=dc.GetNextDocument (doc)
Wend
Else
Messagebox "*** Did Nothing ! ***"
End If

Close f%

scount = Cstr(count)
Messagebox "*** " + scount + " Files have been updated with new Vessel / Voyage and new Dates ***"

Dim workspace As New NotesUIWorkspace
Call workspace.ViewRefresh

End Sub

With

doc.SaveOptions="0"

you create the SaveOptions item, telling the Notes client to NOT SAVE the document.

Have a short look at the documentation about this special item.

And I don't see a reason, why you would set this item in a view action. Just remove this row and test again.

OK, thanks - I removed this line.

Hello Mike,

apart from the doc.SaveOptions="0" problem Thomas mentioned, I would suggest to throw an eye on the

Call notesDocumentCollection .StampAllMulti( document )

method. As you use the same static values for all those documents in the collection this method will be much faster than your code ever can be.

Jochen "Joe" Herrmann

Hi Jochen

This seems like an enticing function, but I could not make this work as expected.

Hi Mike, if Thomas and Jochen's suggestions don't resolve the problem, take a look at the data types you're working with. Based on your variable names it looks like you're operating on date/time fields but the return value from InputBox$ is a string, which you are storing as-is in the document fields.

My recommendation there would be to comment out all field updates except one which only modifies a text field in your document. If that works, reintroduce the other field updates until it starts breaking, then you know which you need to convert before storing them.

Hi Bill

You are correct. I did not realize that the InputBox command returns a variant or when used with a InputBox$ it will return a string. Since I have Date/Time values in the original document that I want to update I have defined the variables as Variants now.

Help needed!

Update - while there are many ways to possible do what I wanted to accomplish in the first place - InputBox, DialogBox, StampAllMulti(Doc)

I have the original and even bigger problem now that I have created those "Zombie Docs" that cannot be edited any more. Since those original documents have hundreds of fields of information in them - we really need to access those again.

I mean we can open them through a View like normal, but if you change any field it will not SAVE this change anymore. No error message appears either. I am at a loss here.

Locking is not enabled in the database and all documents that I have not modified with my script work just fine.

If anybody has any suggestions I would be grateful - this has operational impact now ...

I circle back on the programming part at a later time.

Mike

I guess all those documents have now a field called "SaveOptions", right ? If thats the case, you have to get rid of this field in those documents.

Create an @Formula agent that has to ahve the following Action code:

FIELD SaveOptions := @Unavailable;

then this problem should be tackled.

Here an example for the StampAll Multi method:

Dim Stamp As NotesDocument

Set stamp = ยง.DB.Createdocument
With stamp 'put here all those fields you want to write into the collection
.field1=10
.field2="This & that"
'... 'dont put the Saveoptions here !!!
End With

coll.Stampallmulti stamp 'Now let Notes do the work
'...

Hope this helps.

Sincerly,

Jochen "Joe " Herrmann

Hi Jochen

I was busy taking care of some other problems. Thank you for your reply and I will check your suggestions in the next few days. This sounds like a good lead ...

Mike

Hi Mike,

could you solve the problem ?

Sincerly

Jochen "Joe" Herrmann

I will try soon.

Hi Jochen

Thank you so much. This was it! The #@$% SaveOptions Field that got set wrongly by the script.

Back in business again - now I can give another look at the StampAllMulti function and address the original problem.

I wonder if another problem is that some of the Fields I am updating validate their value via @dblookup and we usually do update with F9 manually when the doc is open. What happens if you update such a field in a closed document via script?

Thanks again.

Mike