Rename Document file with a custom attribute

Hi,

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

(

LONG *hookId*/,

LONG /*hookType*/,

AAPARAM         aParam1,

AAPARAM         aParam2,

AARESULT*       pResult

)

    {

   if (aParam2 !=  AAOPER_DOC_UPDATE_LINK_DATA)

   return AAHOOK_SUCCESS;

    LPAADOC_PARAM pProParam = (LPAADOC_PARAM)aParam1;


if (pProParam->lDocumentId != 0)

the problem is LPAADOC_PARAM dose not return the correct Document ID.

any Idea?

Regards

Ghazi

Parents Reply
  • Ghazi,

    I should warn you that the use of those two calls just happen to work and will probably work 99% of the time, but it is only because it is likely that ProjectWise has already put that information into the buffer that those calls are reading. (Check the documentation for the "proper" use of those calls).

    You can get the document and project ids that you need directly from what is being pass to your hook function and you can be sure that it is correct.

    In your hook, cast aParam1 something like this:

    LPAALINKDATA_HOOK_PARAM pParam = (LPAALINKDATA_HOOK_PARAM)aParam1;

    (You should also check what the value of aParam2 is for "defensive programming" so that you are only processing the operations that you know about. It is possible that additional processes could be added to a hook in the future. )

    Then these values should be available to you:

    pParam->lpLinkage->documentId.lProjectId

    pParam->lpLinkage->documentId.lDocumentId

    pParam->lAttributeRecordId

    HTHs
Children