File Versions and Links in the Selection Set

If you are working with custom Vault Explorer commands or tabs, then you probably deal with selection sets.  Vault 2012 adds some cool new features to make your customizations even better.

There is a new SelectionTypeId value in Vault 2012.  It's called FileVersion, and if it's in the selection set, it means that a specific version of a file has been selected.  Don't confuse this with SelectionTypeId.File, which means a file is selected, but you don't know the version.

Files in the main grid will have SelectionTypeId.File, whereas selections in the history tab will show up as SelectionTypeId.FileVersion.

The meaning of the ID is different depending on the selection type.  For example, if you want to get the File object from the server, you will call either GetFileById or GetLatestFileByMasterId depending on the selection type.

TypeId Id meaning
File File.MasterId
FileVersion File.Id
Folder Folder.Id
Item Item.Id
Bom Item.Id
Change Order ChangeOrder.Id
Other "-1" 
Whatever is selected is not supported.
None Not used

In practice, you usually want to handle both types when dealing with files.  If you have a file command, you set the type as both File and FileVersion.  When you read in a selection set, you check for both File and FileVersion entries.  See Google Map Extension for sample code.


Links

If you have a link to an entity, it shows up in the selection set as the entity itself.  In other words, your code has no idea it's a link.  A link to a file shows up as a file in the selection set.  Also, you can add links to folders, items and change orders.  So for a given folder, it's possible to have links to many different types of objects.  You can no longer assume that it will always be files like in Vault 2011. 

It's possible for a single selection set to contain a mix files, folders, items and change orders.  So you always want to check the type on the ISelection object before you do anything with the Id value.

 
In the above example, the selection set will contain 4 items, one of each entity type that can be a link target.  The rows that indicate the entity type do not show up in the selection set.


Comments

2 responses to “File Versions and Links in the Selection Set”

  1. Balaji A Avatar
    Balaji A

    Hi! Doug, How to get the complete Revision history of a file in vault using .net… Can u please help me with some blog content or samples..
    Thanks in Advance!
    Regards
    Balaji A

  2. First, you call GetFilesByMasterId to get the complete version history. Next, you scan through the versions and pick a single version from each revision. That will give you the revision history.
    There are 2 main ways to pick the version for a revision. You could just pick the one with the highest version number. Or you could do the “released biased” view where you pick the highest version in a released state. If there is no released state, you just pick the highest version.
    Here is an article with some diagrams, which may of help. http://justonesandzeros.typepad.com/blog/2009/10/file-associations-part-2.html

Leave a Reply to Balaji ACancel reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading