Vault Customization

Reply
Valued Contributor
gary.belisle
Posts: 85
Registered: ‎07-29-2011
Message 1 of 5 (257 Views)
Accepted Solution

Item attachment array list

257 Views, 4 Replies
08-08-2012 01:37 PM

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!

---------------------------------------------------------------------
i7-2720QM Dell Precision M6600, Win 7 Pro 64-bit, 8GB RAM
Autodesk Product Design Suite Ultimate 2013
Autodesk Vault Professional 2013
Employee
Redmond.D
Posts: 808
Registered: ‎12-12-2006
Message 2 of 5 (248 Views)

Re: Item attachment array list

08-09-2012 12:30 PM in reply to: gary.belisle

I think GetAttachmentsByItemId is the function you are looking for.



Doug Redmond
Software Engineer
Autodesk, Inc.
http://justonesandzeros.typepad.com/

Valued Contributor
gary.belisle
Posts: 85
Registered: ‎07-29-2011
Message 3 of 5 (238 Views)

Re: Item attachment array list

08-10-2012 09:22 AM 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)

 

---------------------------------------------------------------------
i7-2720QM Dell Precision M6600, Win 7 Pro 64-bit, 8GB RAM
Autodesk Product Design Suite Ultimate 2013
Autodesk Vault Professional 2013
Employee
Redmond.D
Posts: 808
Registered: ‎12-12-2006
Message 4 of 5 (232 Views)

Re: Item attachment array list

08-10-2012 12:44 PM in reply to: gary.belisle

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.
http://justonesandzeros.typepad.com/

Valued Contributor
gary.belisle
Posts: 85
Registered: ‎07-29-2011
Message 5 of 5 (216 Views)

Re: Item attachment array list

08-17-2012 11:40 AM in reply to: Redmond.D

That was the ticket! Thanks Doug!

---------------------------------------------------------------------
i7-2720QM Dell Precision M6600, Win 7 Pro 64-bit, 8GB RAM
Autodesk Product Design Suite Ultimate 2013
Autodesk Vault Professional 2013
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.