db.GetDocumentbyID(ws.currentview.CaretNoteID)

Hi everybody, here is my issue :

I have an action in a view performing the following LS lines:

Set doc2switch = db.getdocumentbyID(ws.currentView.CaretNoteID)

Messagebox doc2switch.AICustomerRef(0)

Messagebox doc2switch.AIScope(0)

My surprise is that the second Messagebox displays an AIScope field different from the field of the concerned doc whereas the first one displays what is expected.

I have noticed that this happens mainly when I have only one document in the view.

Has anyone got an idea of where it comes from?

Subject: RE: db.GetDocumentbyID(ws.currentview.CaretNoteID)

The data are coming from a single document. Both field values are coming from the same document. You must confirm whether this is the same document as the one displayed in the view. Use Msgbox to display the noteID and UNID of the document accessed by your code. Are they the same as those shown by the database properties infobox?

You didn’t show the assignment of your db variable. Can you confirm that it is indeed the current database you are in, or might it be using a hardcoded filepath to access some other copy of the application? By “confirm” I don’t mean “assert,” I mean “test,” i.e. display db.server and db.filepath and compare those with the server and filepath in the database properties infobox.

Please refer to the tips for debugging and how to ask questions for other information you might want to include.

Subject: RE: db.GetDocumentbyID(ws.currentview.CaretNoteID)

Thank you for your fast answer.

I confirm (after having tested) that there is a single document (the document in the view has the same UNID and NoteID as the values called and displayed by my LotusScript) and that I am on the right database on my local desktop.

Do you think of another source of error ?

Subject: RE: db.GetDocumentbyID(ws.currentview.CaretNoteID)

Two possibilities. You might be working with a cached NotesDocument, left behind in memory by a previous agent run. Use the Delete statement to remove NotesDocuments from memory when you are done with them, so that subsequent code execution will reload them from the database.

Secondly, the field might actually not have the value that you think it does. Use the document infobox from a view to see what the value of the field really is. Could it be a keyword field with a synonym, so that the value displayed on a form is not the same as the value stored?

Please read the link I posted before. You’re still leaving out a lot of relevant information.

Subject: RE: db.GetDocumentbyID(ws.currentview.CaretNoteID)

I think the problem comes from the first possibility.

Actually the scenario is the following:

You create a document by a lotusScript action in the given view. Those documents have a form but all their fields are initialized by the script and the form has not been open at this stage yet.

Then you modify some fields (let’s say they are of kind A which is totally arbitrary) either on Form or by another action (still in the view) using a custom dialogbox. The new field value is of course given by the input.

The issue occurs when I used still another action which try to modify some other distinct fields (of kind B), the new values being hardcoded.

Values of kind B are correctly updated (which makes documents disappear from the view and appear in view2 + I checked the InfoBox) but former values of Kind A fields are restored to initial values instead of keeping their current ones (view columns of view2 are displaying former values, infobox as well, and of course messageboxes).

This happens only when there is a new and single document in the view.

Is it more relevant?

I have tried to use the Delete statement but it couldn’t work, I have looked for it in the help and it says that it can be used for objects only, whereas I would need it for a NotesDocument (isn’t a NotesDocument an object?) What can I do ?

Subject: RE: db.GetDocumentbyID(ws.currentview.CaretNoteID)

I’m sorry, but I would need to see the code to make any kind of useful comments. Please read the link I posted before to see what kind of information it is relevant to post.

Yes, a NotesDocument is an object. Yes, you can use Delete on it. Without knowing what you’re trying to do with it, it’s hard to know what you might be doing wrong. But the point is to delete the document after you are done with it in your script. You’re doing this for the benefit of the next script that runs and tries to access the same document.

Dim doc as NotesDocument

…

doc.Save True, True

Delete doc

End Sub

There’s a bunch of Moutons in southern Louisiana, where I grew up. Are you a Cajun lady?

Subject: RE: db.GetDocumentbyID(ws.currentview.CaretNoteID)

Ok I was wrong, the Delete statement works fine :)I still have some issues but I should work them out quite easily now.

Actually I am not Cajun at all since I am French ! :stuck_out_tongue:

Subject: RE: db.GetDocumentbyID(ws.currentview.CaretNoteID)

And yet your writing doesn’t seem to have a French accent. Hm.