doc.RemoveItem method producing strange results

I have never come across this before…

I have a form with some code in the Querysave event that calls a sub (call it Sub A) in a Script Library. In that Script Library, I remove some fields using the .RemoveItem(“(fieldname)”) method for the NotesDocument class.

The fields are removed as they should be when exiting Sub A.

When returning to the Querysave event on the form, the fields are still removed in the document object. I perform a “Source.Reload” in the Querysave event and the fields in the document object are still removed, as well in the Source object. I then perform a “Source.Refresh” and the fields reappear in the document object.

I then call Sub A from the Queryclose event on the Form. The document object has the fields removed and is saved in this Sub A now.

The fields are removed from the document using the Sub A call from the Queryclose event. So it works fine from there.

Why would the fields “reappear” after performing a Source.Refresh. The fields are removed from both the document object and the Source object, so where do they come from?\

I have been using Source.Reload and Source.Refresh together for years and have never seen this happen.

Thanks!

Subject: doc.RemoveItem method producing strange results…

There are 3 documents involved…,

The saved Database copy (Ondisk)

The copy in memory (Backend NotesDocument)

The screen image (Frontend document)

I suspect your script libary is opening up a second Backend document, removing the fields, and saving it to disk … that won’t effect your in-memory copy unless you Reload/Refresh it.

Are you passing a NotesDocument to the script, or a key that’s used to locate the document from a view ?