aaApi_CreateProject is not working

Hello,

I cannot figure out what is wrong with the following code. Do anyone has idea?

This always returns False.

bool createProj(int projectID, LPCTSTR name, LPCTSTR description)
{

LONG projectID2 = 0L;
LONG lngWorkSpaceID = aaApi_GetWorkspaceProfileId(projectID, 0);
LONG userID = aaApi_GetCurrentUserId();
LONG lStorageId = aaApi_GetStorageId(0);

BOOL resultCreate = aaApi_CreateProject(

&projectID2,
projectID,
lStorageId,
userID,
AADMS_PROJECT_TYPE_NORMAL,
0,
lngWorkSpaceID,
0,
name,description);

return resultCreate;

}

  • Did you check to see what is on the ProjectWise error stack? Use aaApi_GetLastErrorId(), etc. to determine why the call failed.

    Also, you aren't showing in this call that you actually filled the static buffers you are using for aaApi_GetWorkspaceProfileId() or aaApi_GetStorageId() which will return a value which may or may not be what you think unless you first filled the buffers based on your needs. See the topic "ProjectWise Data Buffers" under "ProjectWise Developer's Guide" under "Modules" in the SDK help for more about using static and dynamic buffers in ProjectWise.
  • Dan, Thanks for advise. I added aaApi_GetLastErrorId() and got error id 58002. Can you advise where is the error id table? Thank you!
  • Hongseok,

    Sorry, thought it was obvious. Use the other error related calls to get the rest of the error information. In ProjectWise, there are three parts to an error, the id, the message and the detail. Look in the help under "Modules" > "ProjectWise API" > "Error Handling Functions" and you will see that you can get the other two parts as well as the id.

    aaApi_GetLastErrorId()
    aaApi_GetLastErrorMessage()
    aaApi_GetLastErrorDetail()

    TIP:  You can sometimes find specific error codes in the header files.  Try greping them.  For your error code, 58002, I used Notepad++ to search for the regular expression "\#define.*58002" and found this:

    #define AAERR_DMS_ERR_INVALID_ARG  58002

    Which tells me that what I suspected, that one of the values you are getting from a static buffer (that you didn't first fill) is  probably invalid or perhaps one of the parameters that you are passing to your function (parent id, name or description).

  • I would check the values you are passing and ensure that none are zero or -1 (other than ProjectId2). aaApi_GetStorageId needs aaApi_SelectStoragesForProject(ProjectId) , executed prior to it to fill the AADMSBUFFER_STORAGE internal buffer.

  • Thank you so much! It now works.

    bool createProj(int projectID, LPCTSTR name, LPCTSTR description)
    {

    LONG projectID2 = 0L;
    LONG lngWorkSpaceID = aaApi_GetWorkspaceProfileId(projectID, 0);
    LONG userID = aaApi_GetCurrentUserId();
    LONG storageindex = aaApi_SelectStoragesForProject(projectID);
    LONG lStorageId = aaApi_GetStorageId(storageindex);

    BOOL resultCreate = aaApi_CreateProject(
    &projectID2,
    projectID,
    lStorageId,
    userID,
    AADMS_PROJECT_TYPE_NORMAL,
    0,
    0,
    0,
    name,
    description);

    return resultCreate;

    }