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
Solved! Go to Solution.
Solved by Redmond.D. Go to Solution.
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,
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