0
votes

There is an application on Lotus notes 5. The getdocumentbykey function is not working if the view is open. If some other view is open or if the Database is closed then the function is working correctly and finding the document. How can we make it work even if the view is open? I have given the part of the code below. Thank you.

    BillNo2 = cdoc.fieldgettext("Bill_No2")
    Set view = db2.GetView("Bill No.")
    Set doc = view.getdocumentbykey(BillNo2)
    If Not doc Is Nothing Then
        doc.DOdone = "Done"
        doc.LorryNo = cdoc.fieldgettext("Lorry_No")
        doc.TripNo = cdoc.fieldgettext("Trip_No")
        Call doc.save(True, True)
    End If

While debugging, its skipping the line "If Not doc is Nothing" and ends the loop even there is document. The same code works fine if the view is not open. Kindly help me. Thanks.

2
Do the lookup on a hidden view with a similar selection, that cannot be opened by the user?Anders Lindahl
You should consider upgrading Lotus Notes 5 (and maybe also your Domino server?) to the latest version which is 8.5. Lotus Notes 5 was introduced in 1999 and was withdrawn in 2004.Per Henrik Lausten
What's the agent properties is set to run on selected documents, new documents, etc?booyaa
@AndersLindahl: Thank so much. The hidden view worked. I was trying to make a DB search as an alternative which was making the process slower. I din think of this idea.Thanks for the suggestion.Priya
@PerHenrikLausten: Hmm. I suggested the same to the clients. May be the application is so far so good for them :)Priya

2 Answers

1
votes

This sounds like a bug, which is entirely possible given that we're talking about a version that came out 13 years ago. But a few things to check first:

  • Make sure the first column of the Bill No. view is sorted.
  • Make sure the view is not a private view type.

If neither of those are true, or you can't change that view for business reasons, I think Anders's suggested workaround of using a hidden view is an excellent idea and should solve the problem.

3
votes

Working backwards, if fieldGetText is not returning what you expect, your getDocumentByKey call will fail. Have you checked the value of BillNo2 in the debugger prior to the call?

Working backwards further, a reason that fieldGetText would not return what you expect would be that cdoc isn't what you expect. How are you running this code? And what is the code for setting cdoc? Since you use fieldGetText, I presume it is a NotesUIDocument, and guessing from the name I'll bet you're getting it from NotesUIWorkspace.currentDocument. Perhaps the currentDocument in the context that your code is running isn't quite what you expect. I.e., if your code is running in the context of the view, instead of in the context of the document that you're reading from, I would not expect it to work.