I'm new to Vault programming so be gentle!
Using vb.net I'm trying to get all of the files attached to a change order. I am able to get the change order using the code below, but I do not know how to retrieve the files from it. I've searched everywhere but cannot find an answer. Can someone please help?
Dim ECO As ChangeOrder = COService.GetChangeOrderByNumber(ECONo)
Solved! Go to Solution.
Solved by minkd. Go to Solution.
To get the file records for a change order, use the GetAssociationsByChangeOrderIDs() method in the ChangeOrder service, passing "FILE" as the entityClassId parameter.
-Dave
Thanks for your reply!!!!
I'm sorry I don't have a clue what to do with the ChangeOrderEntAssoc that is returned from GetAssociationsByChangeOrderIDs. I've tried everything I can think of to iterate through the array and nothing seems to return the file names associated with the change order. What am I missing?
Here is the code so far...
Public Function GetECOFileNames(ByVal coSvc AsChangeOrderService, ByVal ChangeOrderNo AsString, ByVal docServ AsDocumentService) AsString()
Dim ECO AsChangeOrder= coSvc.GetChangeOrderByNumber(ChangeOrderNo)
Dim ECOs(0) AsLong
ECOs(0) = ECO.Id
Dim ECOAssoc() AsChangeOrderEntAssoc
ECOAssoc = coSvc.GetAssociationsByChangeOrderIDs(ECOs, "FILE")
Dim EntAssoc AsChangeOrderEntAssocDim i AsInteger
ForEach EntAssoc InECOAssoc
ForEach EntID AsLongInEntAssoc.EntIdArray
Dim oFile() AsFile= docServ.GetFilesByMasterId(EntID)
Next
Next
GetECOFileNames = ?
EndFunction
The entity IDs in the return from the GetAssociationsByChangeOrderIDs call are not master IDs. A master ID represents all versions of a file, while the regular ID (some times referred to as the IterationId) represents a specific version of a file. The methods that require masterIDs typically mention "MasterId" in the method name and/or the parameter name.
So the correct call to get the file objects from those IDs is either GetFilesByIds() or GetLatestFilesByIds(), depending on what is more appropriate for your workflow.
There are two names in the file objects: Name and VerName. The Name is the filename that Vault will download the file to (the name of the latest version), and the VerName is the name the file had at a specific version. The two are the same for the Latest File.
-Dave