0
votes

I am getting started with the Lotus Notes C++ API. I am trying to get a document based on UNID. I know a specific UNID, but I do not know how to write it to a UNIVERSALNOTEID.

I am using Lotus Notes 8.5.2, C++ API 8.0.2, Windows 7 64-bit, Visual Studio 2008, C++ (managed).

I am able to open a database.

 ....
 //Get and open a database.
 LNDatabase   SrcDb;
 Session.GetDatabase( c, &SrcDb, chrServer );
 SrcDb.Open();

Then I try to get a document.

 LNDocument ld;
 const UNIVERSALNOTEID u = "00000000000000000000000000000000";
 SrcDb.GetDocument(&u, &ld);

On compile, I receive the error

error C2440: 'initializing' : cannot convert from 'const char [33]' to 'const  
UNIVERSALNOTEID'    

Here is where I need to learn the correct way to pass u to GetDocument.

2
A quick Google search found this documentation. You're trying to assign a string to a structure.Some programmer dude
@JoachimPileborg You are correct, but the documentation that you linked to is for the Notes C API, not the Notes C++ API. The UNID is a fundamental concept in all Lotus Notes development, and the use of different identifiers and representations in the various APIs is a bit confusing.Richard Schwartz

2 Answers

3
votes

LNDatabase::GetDocument takes a UNID* argument, not UNIVERSALNOTEID*.

To get the UNID, use the LNUniversalID class. There's a constructor that takes a string argument, and a GetUniversalID method that returns the pointer to UNID.

1
votes

@Richard Schwartz provided the useful information I needed to create the following code:

//Declare document
LNDocument ld;

//Assign to string, convert to const char *, convert to LNString;
std::string strUNID = "F33DD4EA2E8FD32888257B0A0061C063";
const char * chrUNID = strUNID.c_str();
const LNString * lnstrUNID = new LNString(chrUNID);

//Get UNID *
LNUniversalID * lnUNID = new LNUniversalID(*lnstrUNID);
const UNIVERSALNOTEID * unidUNID = lnUNID->GetUniversalID();

//Get document.
LNSTATUS lsGetDocument;
NOTEID ln;
try
{
    lsGetDocument = SrcDb.GetDocument(unidUNID, &ld);
    LNSTATUS lsStatus = ld.Open();
    ln = ld.GetNoteID();
    Console::Write("NOTEID: ");
    Console::WriteLine(ln.ToString());
}
catch (System::Exception ^e)
{
    String^ eMessage = e->Message;
    Console::WriteLine(eMessage);
}