This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal


Jan 25, 2018, 5:14 PM
5 Posts

NotesDatabase.Search() yielding inconsistem results for custom fields

  • Category: Domino Designer
  • Platform: Windows
  • Release: 9.0
  • Role: Developer
  • Tags: c# domino interop database search
  • Replies: 1

I have made modifications to my mail NSF. I put a menu with buttons to my AppointmentForm that just run a formula that creates an extra field item "MY_CUSTOM_ITEM" with a given value depending on the menu selection.

I have a program written in c# using Domino interop that looks more or less like this:

    NotesSession session = new NotesSession();
    session.Initialize("");
    NotesDatabase db = session.GetDatabase(servername, "mymail.nsf", false);

That is done once, and 'session' and 'db' are stored in a class variable. Then I have a loop that periodically does something like this:

    NotesDocumentCollection col = db.Search("Form = \"Appointment\" & StartTime < @Now & EndTime > @Now & !@Contains(MY_CUSTOM_ITEM;'somevalue')", null, 0);
    object[] obj = (object[])doc.GetItemValue("MY_CUSTOM_ITEM");
    string str = (string)obj[0];

If I set MY_CUSTOM_ITEM to 'anothervalue', save the appointment and start the program, I get str == 'anothervalue'. But if I change the appointment to contain, for example, MY_CUSTOM_ITEM='yetanothervalue', the following iterations of Search() will yield inconsistent results. Most of the time I get the initial result all the time I re-run db.Search(), which is one appointment with str=='anothervalue'. Sometimes I get str=='yetanothervalue', only to see str=='anothervalue' in the next iteration, without me changing anything about the appointment.

I tried the same program with some standard items from Notes appointment. In my case I tested with 'BookFreeTime', which is the item set when you click 'Mark available' in the appointment. In that case I didn't have any problems. Whenever I saved the appointment, Search() yielded a new collection with the updated appointment in it, whith the correct value of 'BookFreeTime'.

The only way I managed to make it work with MY_CUSTOM_ITEM was to instantiate a new NotesSession() on every iteration of the loop. But people are complaining of the amount of sessions being created, and I'm wondering if there is something I could do to make it work without instantiating one session in each iteration, but reusing the same session created at the beginning of the program execution.

Is there something like session.Refresh() or db.Refresh() that could do the trick?

Jan 31, 2018, 8:26 PM
323 Posts
Maybe it's an issue deconstructing or recycling the doc object?

The reaction seems like it's simply left the doc object constructed across the same instantiation of the NotesDatabase.

If the doc object remains loaded, it'll remain what it was last cached.

Given c#, I couldn't tell you whether a recycle() alone would solve the problem, but it's possible it would.

Y'probably need to experiment with calling recycle() on the doc and the col.

Failing that you may need to delete the doc object itself. But I haven't had to do that for a long, long time.


This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal