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: 

Item attachment array list

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
Anonymous
1223 Views, 4 Replies

Item attachment array list

How do I get the ArrayList for any existing Item attachments. I want to add an attachment via the API and keep whatever attatchments already there intact. I can't find the documentation....

 

Thanks!

4 REPLIES 4
Message 2 of 5
Redmond.D
in reply to: Anonymous

I think GetAttachmentsByItemId is the function you are looking for.



Doug Redmond
Software Engineer
Autodesk, Inc.

Message 3 of 5
Anonymous
in reply to: Redmond.D

Thanks Doug.

I'm struggling trying to figure this out. How do I properly Dim the GetAttachmentsByItemId line? I want to add the attachments strings to "fileArray" in the end.

Dim item As Item = Nothing
Dim itemNo As String = ItemArray(i)(0)
Dim itemRev As Item = _
ServiceManager.ItemService.GetLatestItemByItemNumber(itemNo)

item = ServiceManager.ItemService.EditItem(itemRev.RevId) Dim fileArray As System.Collections.ArrayList = New ArrayList fileArray.Add(ItemArray(i)(1)) Dim existingfileArray As ArrayList = _ ServiceManager.ItemService.GetAttachmentsByItemId(itemRev.Id)

 

Message 4 of 5
Redmond.D
in reply to: Anonymous

I almost never use ArrayList objects any more.  The List generic class is much better because you have a strongly typed collection.  With ArrayList, everything is stored as Object.  List allows you to have a collection of only File objects, for example.

 

 

I would do something like this.

 

Dim attachments As Attmt() = ServiceManager.ItemService.GetAttachmentsByItemId(itemRev.Id)

Dim attachmentList As New List(Of Attmt)()

attachmentList.AddRange(attachments)

 

Now you can add items to your attachmentList object.  When it is time to call UpdateItem you can call attachmentList.ToArray() to convert the List to an Attmt() type.



Doug Redmond
Software Engineer
Autodesk, Inc.

Message 5 of 5
Anonymous
in reply to: Redmond.D

That was the ticket! Thanks Doug!

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

Post to forums  

Autodesk Design & Make Report