Community
Vault Customization
Share your knowledge, ask questions, and explore popular Vault API, Data Standard, and VBA topics related to programming, creating add-ins, or working with the Vault API.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

DocumentService.GetFileAssociationsByIds does not return all associations?

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
etckerry
1273 Views, 4 Replies

DocumentService.GetFileAssociationsByIds does not return all associations?

Hello all,

 

I am attempting to generate information similar to the "Where Used" tab in vault within an external application using the Vault API.  I'm using the DocumentService.GetFileAssociationsByIds method and parsing the results as follows:

            assocIds = serviceManager.DocumentService.GetFileAssociationsByIds(New Long() {fileId(0).Id},
                                                                               FileAssociationTypeEnum.Dependency, True,
                                                                               FileAssociationTypeEnum.None, False,
                                                                               True, False)

            For Each assoc As FileAssocArray In assocIds
                If assoc.FileAssocs IsNot Nothing Then
                    For Each fa As FileAssoc In assoc.FileAssocs
                        If fa.ParFile.VerNum = fa.ParFile.MaxCkInVerNum Then System.Console.WriteLine(fa.ParFile.Name)
                    Next
                End If
            Next

 

The result is four different assemblies (with or without the check to see if it's the latest version).

 

When I look at the same part in the vault browser, it tells me this part has 6 direct parents and 31 total parents.  The four assemblies reported by GetFileAssociationsByIds all correspond to one branch (i.e. only one of the IDs returned from GetFileAssociationsByIds corresponds to a direct parent, and only one of that parent's parents is included, etc.)

 

Am I doing something wrong?  What do I need to do to find the complete list of places where this file is used?

 

Thanks,

 

Kerry

4 REPLIES 4
Message 2 of 5
minkd
in reply to: etckerry

First off, I highly recommend using GetFileAssociationLitesByIds instead of GetFileAssociationsByIds.  There are a number of problems with the latter method so we intend to eliminate it in a future release.

 

As to getting different results, the where-used is likely including related documents; which is controlled by the includeRelatedDocuments parameter.

 

-Dave

 



Dave Mink
Fusion Lifecycle
Autodesk, Inc.
Message 3 of 5
etckerry
in reply to: minkd

Thanks for your reply.

 

I'm using Vault 2012 and I don't see GetFileAssociationLitesByIds - maybe this has been added since 2012?

 

I've tried every combination of arguments but I can't get the results I expect.  Even if I pass (id, All, True, None, True, True, True), I only get the 4 out of 31 associated files that I expect.

 

Thanks,

 

Kerry

Message 4 of 5
minkd
in reply to: etckerry

I believe Vault Explorer shows "latest" associations so instead of GetFileAssociationsByIds (actual associations), you should use GetLatestFileAssociationsByMasterIds (latest associations) - beware that it takes file master IDs instead of file iteration IDs.

 

GetFileAssociationLitesByIds was added in 2014.  It replaces all other file association methods.  The "algorithm" (actual, latest, revision, etc) is chosen with the associationAlgorithm parameter. It always takes file iteration IDs, regardless of what kind of associations are requested.

 

-Dave

 



Dave Mink
Fusion Lifecycle
Autodesk, Inc.
Message 5 of 5
etckerry
in reply to: minkd

Yep, that did the trick.

 

Thanks for your help.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report