I want to update the version of a reference of a master dgn to a specified version (not the active one) through aaApi_UpdateDocumentRefVersions.
Firstly, I successfully get the AADMS_REFDOCVERSION_FOR_UPDATE struct by aaApi_GetDocumentRefVersionForUpdate. Then pass it as a parameter to aaApi_UpdateDocumentRefVersions. However, the result is always false. By inspecting error info, it says that "Access denied. You have insufficient privileges to finish this operation". The entire operation is done by a super admin account with use access control unchecked.
What's wrong with my code? Or could you provides some example to show how to use this function?
Here's my code snippet:
const auto master_doc_proj_guid = project::GetFolderGuid(master_doc_item.lProjectId); const auto master_doc_guid = document::GetDocGuid(master_doc_item.lProjectId, master_doc_item.lDocumentId); ULONG count = 0; ULONG flags = 0; AADMS_REFDOCVERSION_FOR_UPDATE * pbuffer; aaApi_GetDocumentRefVersionsForUpdate(0, 0, &master_doc_guid,&flags, &pbuffer, &count); if (!aaApi_UpdateDocumentRefVersions(lp_doc_item, &master_doc_guid, pbuffer, count)) { const auto error_id = aaApi_GetLastErrorId(); MessageBoxW(0, aaApi_GetLastErrorMessage(), 0, 0); MessageBoxW(0,aaApi_GetLastErrorDetail(),0,0); aaApi_RemoveLastError(); } aaApi_Free(pbuffer);
You're right. The trick is that the document must be locked before executing aaApi_UpdateDocumentRefVersions
Snailya Lee, I have not personally used function aaApi_GetDocumentRefVersionsForUpdate() (yet), but looking at the documentation, I suspect that you need to pass a valid mask for the first parameter "flags" as well as a valid pointer to the structure DocItem for the second parameter with valid values. But, I'm only guessing at this point.
You are not checking the return value for aaApi_GetDocumentRefVersionsForUpdate(). What does it return?From the documentation, it appears that your process needs to have the documents "locked", which I interpret as "Checked-Out".
Answer Verified By: Snailya Lee