Moving a folder within the DataSource

I am trying to move a folder in my datasource using aaApi_SetParentProject(childId, parentId).  It doesn't matter what projectId I use for the parent, it always moves the folder to the very top of my documents tree.  What am I doing wrong?

Parents
  • Colin,

    Can you please post a snippet of your code along with indicating what version of ProjectWise Integration Server, Explorer, SDK, Windows OS, and Visual Studio that you are using.

    I assume that you looked at the documentation, so that if you are passing -1 for the parent id, that would explain the behavior you are seeing.  What values are you passing and does the ProjectWise user running the code have the necessary rights?  What value is the function returning, and if it is FALSE, what is the error on the ProjectWise error stack?

    Here's some sample code that "works on my box":

    extern "C" int WINAPI ProjCmd_MoveFolder_UnmanagedCode
    (
    	long  project_no
    )
    {
    	AFX_MANAGE_STATE(AfxGetStaticModuleState());
    
    	CString msg;
    	WCHAR wcInput[6] = L"";
    
    	LONG_PTR lptr = aaApi_GetInputStringDlgW(NULL, L"Parent Project Id", AAINPUTDLG_NEEDS_MODIFY_BEFOREOK,
    		NULL, L"Enter the Parent's Project Id", wcInput, sizeof(wcInput) / sizeof(WCHAR));
    
    	long parentId = _wtol(wcInput);
    
    	if (!aaApi_SetParentProject(project_no, parentId))
    	{
    		msg.Format(L"This is unmanaged code called from an .mrr file.\n\n[%ld]\n%s\n%s",
    			aaApi_GetLastErrorDetail(),
    			aaApi_GetLastErrorMessage(),
    			aaApi_GetLastErrorDetail());
    	}
    	else
    	{
    		msg.Format(L"Folder moved!");
    	}
    
    	AfxMessageBox(msg, IDOK | MB_ICONINFORMATION);
    
    	return 0;
    }
    

    I did my testing on a Windows 10 machine, running ProjectWise Explorer v10.00.03.167, SDK v10.00.03.140, VS 2015 against a ProjectWise Integration Server v 10.00.02.265.

    Dan Williams
    Solution Consultant
    Bentley Systems, Incorporated
    Portland, OR, USA (Pacific Time UTC-08:00)

Reply
  • Colin,

    Can you please post a snippet of your code along with indicating what version of ProjectWise Integration Server, Explorer, SDK, Windows OS, and Visual Studio that you are using.

    I assume that you looked at the documentation, so that if you are passing -1 for the parent id, that would explain the behavior you are seeing.  What values are you passing and does the ProjectWise user running the code have the necessary rights?  What value is the function returning, and if it is FALSE, what is the error on the ProjectWise error stack?

    Here's some sample code that "works on my box":

    extern "C" int WINAPI ProjCmd_MoveFolder_UnmanagedCode
    (
    	long  project_no
    )
    {
    	AFX_MANAGE_STATE(AfxGetStaticModuleState());
    
    	CString msg;
    	WCHAR wcInput[6] = L"";
    
    	LONG_PTR lptr = aaApi_GetInputStringDlgW(NULL, L"Parent Project Id", AAINPUTDLG_NEEDS_MODIFY_BEFOREOK,
    		NULL, L"Enter the Parent's Project Id", wcInput, sizeof(wcInput) / sizeof(WCHAR));
    
    	long parentId = _wtol(wcInput);
    
    	if (!aaApi_SetParentProject(project_no, parentId))
    	{
    		msg.Format(L"This is unmanaged code called from an .mrr file.\n\n[%ld]\n%s\n%s",
    			aaApi_GetLastErrorDetail(),
    			aaApi_GetLastErrorMessage(),
    			aaApi_GetLastErrorDetail());
    	}
    	else
    	{
    		msg.Format(L"Folder moved!");
    	}
    
    	AfxMessageBox(msg, IDOK | MB_ICONINFORMATION);
    
    	return 0;
    }
    

    I did my testing on a Windows 10 machine, running ProjectWise Explorer v10.00.03.167, SDK v10.00.03.140, VS 2015 against a ProjectWise Integration Server v 10.00.02.265.

    Dan Williams
    Solution Consultant
    Bentley Systems, Incorporated
    Portland, OR, USA (Pacific Time UTC-08:00)

Children