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?
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
WCHAR wcInput = 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",
AfxMessageBox(msg, IDOK | MB_ICONINFORMATION);
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 WilliamsSolution ConsultantBentley Systems, IncorporatedPortland, OR, USA (Pacific Time UTC-08:00)
For the moment, I am just testing an overall workflow, so I am simply hard-coding a test folder as the childId, and various other folders for parentIds. The function always returns TRUE.
Here is the specific line of code, as it stands at the moment:
bool success = PWWrapper.aaApi_SetParentProject(139355, 29802);
I have tried using multiple parent folder ID numbers, all to the same effect.
I am using VS2019, ProjectWise Explorer 10.00.02.320, Windows 10, SDK 10.00.2265. Integration server 10.00.0020.
Well, I can't explain why it isn't working for you. Obviously, something is different, but determining what will require more information, testing, and thought.
Obviously, since we are using different versions of ProjectWise, it might be a bug, but I think that would be unlikely. Perhaps a difference in the compilers?
If you can, consider trying your code with VS 2015 as that is the officially supported version of VS for the SDK now days.
Does my code work on your box, or is it just your code that is failing? If you didn't try my code, I would encourage you to do so, that way we can focus on the differences between the working code and the non-working code.
Can you move the folders using ProjectWise Explorer for the same datasource/folder/user - to rule out security or user/datasource settings?
If you want, we can exchange code via some private means if you don't want to post yours. I updated my sample for using C# with mrr files to test this, so I could zip that up and make it available to you. I'm using C++ for my testing. The code I posted above is for an MFC Dll called from an .mrr file.
In my testing, I was able to force the API function to fail. I don't remember what I did to force the error, probably keyed in a bogus parent or child folder id, but I know that I was able to get the function to return false and there was a valid ProjectWise error on the error stack.
And lastly, since you are calling the function from a wrapper, perhaps your PInvoke data is wrong?
Here's how it is setup in MostOfDavesClasses:
[DllImport("dmscli.dll", CharSet = CharSet.Unicode)]
public static extern bool aaApi_SetParentProject
int lChildId, /* i Child project number */
int lParentId /* i Parent project number (<0 top) */