Wrong return on aaApi_IsDocumentCheckedIn?

I am using the following code to determine whether a document is checked in to ProjectWise and it seems to be returning the wrong answer. Does anyone have a clue as to why?

wchar_t reqName[]=_T("CreateProjects.txt");

long projID = aaApi_GetProjectIdByNamePath(devPath);

long reqID = aaApi_SelectDocumentsByNameProp (projID, reqName, NULL, NULL, NULL);

if (!aaApi_IsDocumentCheckedIn(projID, reqID))

{

AfxMessageBox(_T("Document is checked out"));

}

-----

I can manually check out the document using the same login as when the API is running, and it appears the folder ID is correct. In my code, I tried ignoring the checkout status and used:

if (aaApi_CheckOutDocument(projID, reqID, reqFolder, NULL, 0))

to try to check document out, but got an error and the message was: 

Error checking out a file of document '573932:1'.

The numbers correspond to the folder and document ID sent to the API function.

 

Thanks for any assistance,

Stephanie

  • I recommend capturing all functions return codes (status or error) and react accordingly, by reporting a clear error outside the documented acceptable range expected and exiting the function as early as possible.  Even functions that return a BOOL may provide more details by calling Both: aaApi_GetLastErrorMessage() and aaApi_GetLastErrorId().  Could you check the return codes for aaApi_IsDocumentCheckedIn() as being true and obtain a specific ErrorId for aaApi_CheckOutDocument() when false?



  • Stephanie,

    Assuming that the call to aaApi_GetProjectIdByNamePath() returns a valid project id (you should check the return code - see the documentation), then your call to aaApi_SelectDocumentsByNameProp() returns the COUNT of documents returned in the buffer AADMSBUFFER_DOCUMENT, not an ID of a document, or it returns an error flag. Again, check the documentation.

    You can get the document’s ID with a call to aaApi_GetDocumentNumericProperty() but make sure that you understand that there might be zero, one or more documents in the buffer, so you might want to also make a call to aaApi_GetDocumentStringProperty() and verify that the document’s name (or filename) is what you are looking for.

    I don’t know off the top of my head for these functions, but some select document functions will also return document versions, so you should probably check to see if the ones you use also return versions, and if they do, take that into account as well.

     

    Answer Verified By: Stephanie Doherty