Adding Attachments using VB code

Adding Attachments using VB code

shashipatra
Contributor Contributor
689 Views
3 Replies
Message 1 of 4

Adding Attachments using VB code

shashipatra
Contributor
Contributor

Is there a way to do the attachments using the VB code .

 

Manual Method :

First I select the File i want to add attachment. Then under Action Menu - > Attachments

I get two options to Attach and Detach. I can choose Attach option and select the File to attach.

 

AutoMated way Required :

I have a Excel File in the following format :

 

Data looks like this

FileName    Attachment

456224       MfgAtt1

456225       MfgAtt2

456226       MfgAtt3

456227       MfgAtt4

 

All the Files and attachment files are already present in Vault.

 

I need Programatcially find the File and do the attachment .

 

Thanks

0 Likes
690 Views
3 Replies
Replies (3)
Message 2 of 4

Daniel.Dulzo
Alumni
Alumni

Hi shashipatra,

 

It sounds like you'd like to write a program that iterates though the data in the excel file and creates these attachments for you. I'm not too familiar with programming with excel files, but I can hopefully give you some guidance on the Vault side of things.

 

First, you want to know how to find the files identified in the Excel file. The DocumentService.FindFilesBySearchConditions() can be used to search for files that meet certain search criteria. An example how of to use it can be found as part of the SDK install. Look at the VaultFileBrowser sample's FinderForm.cs (or .vb) for an example.

 

Secondly, you need to create new attachments for these files. You can add you're own attachments programmatically using the DocumentService.CheckinFile() method that is part of the Vault SDK. To add an attachment to a file, first check out the file, then check it back in after adding a new FileAssocParam to the associations array. The new FileAssocParam should have a type of attachment and the child file property should point to the file you wish to attach. More information on the CheckinFile() method and its parameters can be found in the SDK documentation.

 

Some additional information on attachments can also be found here: http://justonesandzeros.typepad.com/blog/2010/11/attachments-and-dependencies-faq.html.



Daniel Dulzo
Software Engineer
Autodesk, Inc.
0 Likes
Message 3 of 4

shashipatra
Contributor
Contributor

I dont care about the excel auotmation Part.

 

I have a file : EngDwg1.dwf in vault and have a file EngDwgAttach.dwf in vault also (I am not adding the file its already present in vault) , i also know the path where this file is located.

 

Need a VB Call which will attach EngDwgAttach.dwf to EngDwg1.dwf .

 

Thanks.

 

0 Likes
Message 4 of 4

Daniel.Dulzo
Alumni
Alumni

You should use the DocumentService.CheckinFile() method to add an attachment to a file. Follow the steps below to create the attachment:

 

  1. check out EngDwg1.dwf with DocumentServices.CheckoutFile()
  2. get the existing file relationships for EngDwg1.dwf via DocumentServices.GetFileAssociationsByIds()
  3. check in EngDwg1.dwf via DocumentServices.CheckinFile() using an array of the file associations including both the old file associations and the new file association of the EngDwgAttach.dwf as an attachment


Daniel Dulzo
Software Engineer
Autodesk, Inc.
0 Likes