'Error 4005 : User-defined error' on call doc.Save

Can anyone give me some ideas on how to track down the following problem.

When the following piece of code runs, I get a ‘Error 4005: User-defined error’.

Set doc = collection.GetNthDocument(i)

doc.SigRevBy = dummydoc.RevName(0)

Set doc.SigRevDate = New NotesDateTime(dummydoc.RevDate(0))

Call doc.Save(True, True)

I have watched it run in the LotusScript Debugger many times trying to get it past the Save. I do not see any LotusScript code that may be run by the Save, so I am assuming that it is the Save itself that is having the problem.

I have put a Save in before the fields are changed and that appears to work fine.

I have commented out the two statements that change the fields, and added a statement that adds a simple text field. The Save still fails.

Please let me know if I am missing something.

Subject: RE: ‘Error 4005 : User-defined error’ on call doc.Save

That error number is often associated with the error “you are not authorized to perform that operation.” Might there be an access issue preventing you from updating the document?

It looks like you’re trying to update some signature fields. Are they in a controlled access section, by any chance?

Subject: RE: ‘Error 4005 : User-defined error’ on call doc.Save

The fields that are being changed do not effect my access to the documents. Any other suggestions?

Subject: RE: ‘Error 4005 : User-defined error’ on call doc.Save

The fields that are being changed do not effect my access to the documents. Any other suggestions?

I think you must not have read my message carefully enough, because you answered a question I didn’t ask, and didn’t answer the one I did ask.

Here’s another one for you: Can you make this change by manually editing the document? If not, what prevents you?

Subject: RE: ‘Error 4005 : User-defined error’ on call doc.Save

I can update the documents through the normal notes interface and an agent that uses the formula language instead of LotusScript. As I said in my original post, I can add a doc.Save to the code before any fields are changed, and it works. As soon as I change any field on the document, doc.Save fails.

Subject: RE: ‘Error 4005 : User-defined error’ on call doc.Save

Additional information: This only happens when the agent is run from a private view.

Subject: RE: ‘Error 4005 : User-defined error’ on call doc.Save

Is this a “private” or “desktop private” view?

You use a variable named collection which I assumed was a NotesDocumentCollection – is it? How was it assigned? Do you have a NotesView object in your script?

I think your problem lies not in the updating of the document, but in the automatic updating of the view index as a consequence of updating the document. It may be that there’s a different way to get the document collection which will not cause this problem. If you have a NotesView object in your script, be sure to set its AutoUpdate property = False.

Incidentally, this is not the cause of your error, but never use GetNthDocument in a NotesDocumentCollection if it contains more than a few documents. GetFirstDocument and GetNextDocument are a lot faster.

Subject: RE: ‘Error 4005 : User-defined error’ on call doc.Save

This is just a private view I created and it is not used in the script. The collection is assigned with the db.UnprocessedDocuments command.

This is was a good suggestion, since I know that Lotus script does not work with private views well. Unfortunately, it did not make a difference. I set AutoUpdate to false in the view’s QueryRecalc event and set its refresh property to Manual, and I still get the 4005 error on the doc.Save.

Subject: RE: ‘Error 4005 : User-defined error’ on call doc.Save

I think you’re going to have to contact support on this one – it doesn’t seem to be a known issue.

You didn’t state clearly whether this is a server private or desktop private view. There’s not normally a problem using server private views in LotusScript.

Setting the Autoupdate property in a server event isn’t going to do any good. If you’re not actually using the view in your script, you’re not going to be able to affect when it refreshes.

Is there any chance the view selection formula is time-based, such that any change you make to a document will affect its membership in the view?

Subject: RE: ‘Error 4005 : User-defined error’ on call doc.Save

This function does not have a problem from a private view on the server, the error only occurs in a local replica. Can you tell me why it might be different?

Subject: RE: ‘Error 4005 : User-defined error’ on call doc.Save

Joseph Pollone’s observation that deleting and recreating the view seems to solve the problem, makes me think that you can probably also fix it with a Shift+F9 in the view.

I wasn’t asking whether you were using a server replica or a local replica, though that is also good information. I was wondering whether this is a regular “private” view, of the type that also would exist in a server replica, or whether it’s a “desktop private” view. Using the Properties dialog in the view of views in Designer, what is the value of its $Flags item?

Subject: RE: ‘Error 4005 : User-defined error’ on call doc.Save

Andre,

I have received this message in the past as a server private view but it seems to be a problem with desktop private views too. If I delete the private views (by deleting the icon from the workspace), the error goes away. The error will return after some time.

I wish I could automatically delete all private views on database close.

Also, the private view does not work well with form formulas. It is unfortunate, but I like to use both form formulas with privates views.

I have tested with the designer client 6.5.2.

Subject: ‘Error 4005 : User-defined error’ on call doc.Save

on which line did you get the error ?

try with erl to get the line

Subject: RE: ‘Error 4005 : User-defined error’ on call doc.Save

I get the error on the doc.Save statement.

Subject: ‘Error 4005 : User-defined error’ on call doc.Save

I realize this is an old thread, but I hadn’t seen any solution posted recently. I was also receiving a similar error (mine was 4000, but also listed as “User-defined error”).

I discovered that I had been haphazardly appending fields to the document in question using item.ReplaceItemValue commands until it had reached a size in excess of 64KB of text. With a document that large, the doc.Save will fail. I split the single document into a series of child documents and the doc.Save errors went away.