Attribute Sheets: How do you tell if they are missing and how do you add one?

I have a program that changes storage area for a tree. As a part of this change, it creates a temporary folder and moves the documents to that temporary folder.  It hangs, so that I have to close ProjectWise, if a document does not have a sheet.  Which functions allow me to check for the existance of a sheet and which functions allow me to add a sheet if there is not one, both without bringing up a dialog?  All of the aaApi_AttributeSheet... functions seemed to bring up a dialog, rather than just adding a blank sheet.

Parents
  • Dean,

    Take at look at the Link Functions under ProjectWise DMS API module in the help file and in particular aaApi_SelectLinks() to determine if a document has zero, one or more attribute rows (links) in an environment.

    To add a "sheet" ( a row in the environment table for a document), take a look at these three functions:

    aaApi_FreeLinkDataInsertDesc()

    aaApi_SetLinkDataColumnValue()

    aaApi_CreateEnvAttr()

    Note:  Don't use aaApi_CreateLinkData(), aaApi_CreateLinkDataAndLink() or aaApi_GetLinkDataUniqueValue() as they are for legacy code.

    You also need to understand that when you "move" a document from one folder to another, underneath it all, what is happening is a copy and then a delete so this changes the project "ID" and the document "ID" but the GUID stays the same.  Unfortunately, GUIDs aren't used to link documents to user attributes, so that all has to be dealt with by the underlying API code.  So, assuming that the source and target folders have the same environments, make sure that the settings on the General tab for the properties of each attribute in the environment under "Clear Attribute value when" is what you want or account for it in your code.

    If your code is "hanging", then there's probably something that you are not accounting for in your logic or perhaps you are not checking the return codes for the calls to the API functions.

    Have you considered using aaApi_MoveDocument()?  It might do what you want for the part about moving to a "temporary folder".

    Answer Verified By: Dean Lyon 

Reply
  • Dean,

    Take at look at the Link Functions under ProjectWise DMS API module in the help file and in particular aaApi_SelectLinks() to determine if a document has zero, one or more attribute rows (links) in an environment.

    To add a "sheet" ( a row in the environment table for a document), take a look at these three functions:

    aaApi_FreeLinkDataInsertDesc()

    aaApi_SetLinkDataColumnValue()

    aaApi_CreateEnvAttr()

    Note:  Don't use aaApi_CreateLinkData(), aaApi_CreateLinkDataAndLink() or aaApi_GetLinkDataUniqueValue() as they are for legacy code.

    You also need to understand that when you "move" a document from one folder to another, underneath it all, what is happening is a copy and then a delete so this changes the project "ID" and the document "ID" but the GUID stays the same.  Unfortunately, GUIDs aren't used to link documents to user attributes, so that all has to be dealt with by the underlying API code.  So, assuming that the source and target folders have the same environments, make sure that the settings on the General tab for the properties of each attribute in the environment under "Clear Attribute value when" is what you want or account for it in your code.

    If your code is "hanging", then there's probably something that you are not accounting for in your logic or perhaps you are not checking the return codes for the calls to the API functions.

    Have you considered using aaApi_MoveDocument()?  It might do what you want for the part about moving to a "temporary folder".

    Answer Verified By: Dean Lyon 

Children