C++ API - Get entries in categorized view

Hello!

I hope that my question is not absolutely stupid since I’m just starting to use the Notes-C+±API.

What I want to do is opening a categorized view, grab all the entries that belong to one single category and iterate over the documents.

In LotusScript one would either use:

Set viewNavigator = notesView.CreateViewNavFromCategory(category)

  • or -

Set documentCollection = notesView.GetAllDocumentsByKey(category, true)

Using the C+±method LNViewFolder::Find, searching for the category, the result is just one single entry, which is the category itself. There seems to be no method to get all the entries belonging to a category!

The only way I could find to solve my problem, can be seen in the quick-and-dirty code below. After finding the category, I use its LNVFPosition to go to the position in the view and iterate over its child-documents.

This works, but for me this doesn’t seem to be the way one should do this (Just a Workaround? Inefficient?). Does anybody know of an “official”, more elegant way to do what I want to do? Did I oversee an important Object or method? Or can anybody confirm that this is the right way to solve this task?

Thank you very much in advance!

(Already posted this question in the Notes 4/5 forum, but this forum here seems to be a lot more active…)

#include

#include

#include <lncppapi.h>

#define ERR_BUF_SIZE 512

using namespace std;

int main(int argc, char *argv)

{

char *dbFilename = “names.nsf\0”;

char *dbServer = “CN=SNTSN2/O=SSB\0”;

LNNotesSession session;

LNDatabase db;

LNViewFolder viewFolder;

LNSetThrowAllErrors(TRUE);

try

{

session.Init();

session.GetDatabase(dbFilename, &db, dbServer);

db.Open();

db.GetViewFolder(“($ServerAccess)”, &viewFolder);

viewFolder.Open();

LNVFFindOptions findOptions;

findOptions.SetMatchCase(FALSE);

findOptions.SetMatchWholeWord(TRUE);

LNDocument document;

LNVFPosition position;

LNText groupNameItem;

LNVFEntry entry;

LNSTATUS status;

LNINT count;

LNString username = session.GetUserName();

viewFolder.Find(username, findOptions, &entry, &count);

if (count == 1)

{

entry.GetPosition(&position);

viewFolder.SetPosition(position);

status = viewFolder.GotoChild(&entry);

while (status != LNWARN_NOT_FOUND)

{

entry.GetDocument(&document);

document.Open();

document.GetItem(“ListName”, &groupNameItem);

cout << LNString(groupNameItem[0]) << endl;

document.Close();

status = viewFolder.GotoNextSibling(&entry);

};

}

viewFolder.Close();

}

catch (LNSTATUS lnError)

{

char errorBuf[ERR_BUF_SIZE];

LNGetErrorMessage(lnError, errorBuf, ERR_BUF_SIZE);

cout << "Error: " << errorBuf << endl;

}

if (db.IsOpen()) db.Close();

session.Term();

return (0);

}