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: 

How to change the Category on a File?

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
joe
Contributor
1779 Views, 2 Replies

How to change the Category on a File?

I am trying to write a function that will change the category of a file in the vault. I am using Vault Professional 2014. I understand the principle of checking out the file first, then making the category change, then checking the file back in.

I have written code that checks the file out and checks it back in again using the VDF route.

Sadly, no matter how hard I look, I cannot figure out why UpdateFileCategories crashes with a SOAP exception. I realise a similar post was raised a couple of days ago, but I think my issue is just inexperience with the VDF.

I would appreciate any help or comments. I include the code below:

 

 

 

Private Sub ChangeFileCat(ByRef PassFile As File, _
                              PassCat As VDF.Vault.Currency.Entities.EntityCategory, _
                              VaultConnection As Connection)

 

        'check out file
        Dim fileItem As VDF.Vault.Currency.Entities.FileIteration = _
            New VDF.Vault.Currency.Entities.FileIteration(VaultConnection, PassFile)
        Dim oSettings As Vault.Settings.AcquireFilesSettings = _
            New Vault.Settings.AcquireFilesSettings(VaultConnection)
        oSettings.DefaultAcquisitionOption = _
            Vault.Settings.AcquireFilesSettings.AcquisitionOption.Checkout Or _
            Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download
        oSettings.AddEntityToAcquire(fileItem)
        oSettings.LocalPath = VaultConnection.WorkingFoldersManager.GetWorkingFolder(fileItem)
        VaultConnection.FileManager.AcquireFiles(oSettings)

 

        'attempt to change the CATEGORY
        VaultConnection.WebServiceManager.DocumentServiceExtensions. _
          UpdateFileCategories(New Long() {PassFile.MasterId}, New Long() {PassCat.ID}, "CAT CHANGE")

 

        'Checkin the File
        VaultConnection.FileManager.CheckinFile(fileItem, _
            "TEST", False, New ACW.FileAssocParam() {}, Nothing, False, _
            Nothing, ACW.FileClassification.None, False)
End Sub

2 REPLIES 2
Message 2 of 3
Redmond.D
in reply to: joe

It's usually good to include the contents of the error when posting to these forums.  Here is some code you can use to extract some useful data out of a Vault SOAP exception.  http://justonesandzeros.typepad.com/blog/2011/11/getting-the-restriction-codes.html

 

Anyway, looking at your code, I'm guessing that the problem is that the file is checked out.  UpdateFileCategories only works if the file is checked in.  Some update functions require the file to be checked out and others require the file to be checked in.  The documentation is supposed to state requirements like this, but that didn't happen on UpdateFileCategories for some reason.  I'll pass this issue along to our tech writer.



Doug Redmond
Software Engineer
Autodesk, Inc.

Message 3 of 3
joe
Contributor
in reply to: Redmond.D

Doug,

 

Yes, couldn't see the woods for the trees. Removing the checkin \ checkout mechanism just sorted the code.

 

Many thanks

 

Joe

 

Private Sub ChangeFileCat(ByRef PassFile AsFile, PassCat As VDF.Vault.Currency.Entities.EntityCategory, VaultConnection AsConnection)

 

VaultConnection.WebServiceManager.DocumentServiceExtensions.UpdateFileCategories(NewLong() {PassFile.MasterId}, NewLong() {PassCat.ID}, "CAT CHANGE")

 

End Sub

 

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

Post to forums  

Autodesk Design & Make Report