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 

  • I will look at those functions. I forgot attribute functions were called LinkData. I am using aaApi_MoveDocument() in my code. Documents without attribute sheets also cause errors with cut and paste in the UI. The UI hangs, then eventually throws an error for each document. I would paste my code but it is rather lenghty and not sure it would help. Is there a flag on MoveDocument that would create the attribute sheet if it does not exist? I don't need to preserve the DocumentID. I use this code when someoen has not setup a folder in the correct Storage location, or when a hard drive is approaching its limit and we need to move files to another Storage location. I believe I will link the document before performing the move since I use the flag AADMS_DOCCOPY_ATTRS. I will report back if this resolves the issue. I belive it should.
  • Dean,

    You mention that the  UI hangs, then eventually throws an error for each document.  What error does it report?

    The flags are documented in the help file.  Some of them as you can imagine can add considerable time to the process such as enabling the audit trail "feature" to copy audit trail records when a document is copied, security, and of course if you have any custom hooks, they could impact what happens as well.  I don't see anything that would create an attribute sheet if there wasn't one to copy.  

    I am curious why it appears that not having an attribute row (sheet) causes a problem.   I don't see why it would.  Is there something specific about those documents, folders, environment, or perhaps the datasource itself that would explain why it appears to cause a problem?

    As for preserving the document id, don't attempt to do that as the document id is not meant to be something that you as  a user or as a developer would set.

    One of the underappreciated features, IMHO of ProjectWise projects is the fact that you as an administrator can limit which "resources" can be used within the project (tree) such as storage locations.  Check that out and perhaps that can help limit the times when someone uses the "wrong" storage area (or other resource) within a project by only allowing them to pick from an "available" list.

    Also, it may be wise to make sure that the way storage areas are created and managed limit the need for moving documents from one storage area to another since, as you are well aware of, ProjectWise doesn't make changing the storage area for existing documents possible without "moving" them to a folder with the "correct" storage area, etc. unless of course you create a tool to do the tedious work for you.  ProjectWise does allow you to "move" an entire storage area to another physical location of course, so if you define your storage areas to reflect such limitations as storage area availability, location, political "boundaries", etc. you can just change the location of the storage area, rather than trying to change the storage area used by specific documents.

    Hope this helps.

  • I am now planning to use AADMS_DOCCOPY_ATTRS only if an attribute sheet exists, and to not use it if the sheet does not. Currently all of our storage areas are on one drive. For about a year, the ProjectWise administrator has been using this tool to correct errant folders that were copied from somewhere and kept their storage area. The challenge now is moving portions or all of a storage area to a new location because the drive only has 10% space left. I was attempting to use this program to facliltate that task. Is there a way to have Administrator move the files? I have always had to sync the files manually, then change over the storage location, then delete the original location. Is there a way to do that in Administrator now?

    You asked about the error when using Cut and Paste from the UI.  The error message reads: "Error Getting Attributes from the copied/moved document. The attribute page may have been removed."

Reply
  • I am now planning to use AADMS_DOCCOPY_ATTRS only if an attribute sheet exists, and to not use it if the sheet does not. Currently all of our storage areas are on one drive. For about a year, the ProjectWise administrator has been using this tool to correct errant folders that were copied from somewhere and kept their storage area. The challenge now is moving portions or all of a storage area to a new location because the drive only has 10% space left. I was attempting to use this program to facliltate that task. Is there a way to have Administrator move the files? I have always had to sync the files manually, then change over the storage location, then delete the original location. Is there a way to do that in Administrator now?

    You asked about the error when using Cut and Paste from the UI.  The error message reads: "Error Getting Attributes from the copied/moved document. The attribute page may have been removed."

Children
  • Dean,

    Hopefully, no one has been inserting, updating or deleting anything directly in the ProjectWise database.  It sounds like to me that there may be some data corruption in one or more tables. 

    Bentley does not publish the database schema for numerous (and valid) reasons, so please don't consider my comments about the database schema "official" in any way.  However, if you look at the document table (dms_doc) you can imagine that the column o_docguid is the "primary key" but also that o_projectno and o_itemno are an "intelligent key" for that document.  That pair of columns is also in the link table dms_link and in the environment table (name depends upon what you named it).  But the link table also uses those column values and a third one dms_link.o_colvalue, to join to your environment table using column a_attrno. 

    I've seen cases, for one reason or another, where there are "valid" rows in dms_link that "point" to actual documents, but the rows that these "point" to in the environment table are no longer available (or never were).  I suspect that this is the case for your data.  How that happened is difficult to say, but you can check to see if every row in dms_link "points" to a row in dms_doc (join on o_projectno and o_itemno) and then check to make sure every row in dms_link actually "points" to a row in your environment table.  That part is a bit more complicated, but if you join on o_projectno, o_itemno and o_colvalue = envtbl.a_attrno then for every row in dms_link for that environment, you should get a row in your environment table (for a given environment, i.e. value for o_tabno).

    Since you have been "moving" documents with code and you admit that it sometimes "hangs", it is possible that you introduced some of these "orphaned" rows (no blame intended) as perhaps the process was interrupted at a critical point.  (Another good reason to have a development system separate from production!)

    Of course, this is just conjecture on my part as I don't have access to your database and its data, or your code to investigate further.  You might want to consider creating a new and empty datasource, import your current environment (export first from your existing datasource) and do some testing to see if the problem occurs in the new datasource without any customizations, and if it does, perhaps determine why.

    You may want to contact Bentley Support to investigate why when you move a document with the built in move command, it fails with that particular error message.

    As to your question "Is there a way to do that in Administrator now?".  The administrator client does not move any files and isn't likely to do so in the future as there are many factors that come into play.  The administrator client, as you probably know, only "moves" the logical location for a storage area.  The actual move (or copy) of the directories and files in the old location of the storage area to the new location must be done outside of the ProjectWise Administrator.

     

  • at this point, I am going to move the files and repoint the storage location. I will have to have some down time for projectwise to do it that way, but it can't be helped. I was testing and trying to figure out what to do. maybe my test area was compromized in some way. The program usually has no issues in it's regular use. I do not have any programs that put data into the tables directly and always use the api, even for executing selects against the data.