I have a custom attribute called file ID and it is uniqe, I wont to use this attribute's value to be as the name of document file. once user clike ssave in properties page.
I used "AAHOOK_UPDATE_LINK_DATA"
LONG AAAPIHOOK Hook_PreModifyDocument2
if (aParam2 != AAOPER_DOC_UPDATE_LINK_DATA)
LPAADOC_PARAM pProParam = (LPAADOC_PARAM)aParam1;
if (pProParam->lDocumentId != 0)
the problem is LPAADOC_PARAM dose not return the correct Document ID.
Hi Dan,As I mentioned earlier, see above, when I tried:
LPAAEALINKAGE lPLinkage = pDocParam->lpLinkage; //But can't get linkage. Don't know why?
So I can't get the likage, let alone documentId, why?
Dan WilliamsSolution ConsultantBentley Systems, IncorporatedPortland, OR, USA (Pacific Time UTC-08:00)
Please check your private message.
I think your casting way is the same as mine, we all got a pointer to AAHOOK_UPDATE_LINK_DATA. I tried to debug using your code. Still got the same error when tring to get the linkage. All other members are good, like ulMask, lTableId, lAttributeRecordId.
I believe the documentation for AAHOOK_UPDATE_LINK_DATA is incomplete. From notes I have in code that uses this hook, whenever the operation from aAparam2 is AAOPER_DOC_UPDATE_LINK_DATA, lpLinkage is not defined. This has also been my experience with it.
As you've already found, the only way to get the Doc Id in this scenario is to use aaApi_SelectLinksByAttr and then aaApi_GetLinkNumericProperty.
Please note that I post here on a voluntary basis and am not a Bentley employee.
The hook AAHOOK_UPDATE_LINK_DATA will get called each time a document attribute sheet is updated. When you update multiple document attribute sheets in a single action, the hook will still get called for each, individually. The way I handle getting the document Id in the case of operation AAOPER_DOC_UPDATE_LINK_DATA in my post hook function is something like this:
LONG AAAPIHOOK HookUpdateLinkData_Post (LONG hookId,LONG hookType,AAPARAM aParam1,AAPARAM aParam2,AARESULT* pResult)
LPAALINKDATA_HOOK_PARAM pParam = (LPAALINKDATA_HOOK_PARAM)aParam1;
LONG lEnvCount = aaApi_SelectEnvByTableId(pParam->lTableId);
if (lEnvCount == 1L)
CString sAttrRecId = L"";
LONG lDocLinkCount = aaApi_SelectLinksByAttr(
if (lDocLinkCount == 1)
LONG lProjectId = aaApi_GetLinkNumericProperty(LINK_PROP_PROJECTID,0L);
LONG lDocumentId = aaApi_GetLinkNumericProperty(LINK_PROP_ITEMID,0);
// Now that you have identified your document, populate the static document buffer.
LONG lDocCount = aaApi_SelectDocument(lProjectId,lDocumentId);
// Do whatever you need here.