Vault Customization

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

Item attachment array list

241 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
Posts: 761
Registered: ‎12-12-2006
Message 2 of 5 (232 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: 80
Registered: ‎07-29-2011
Message 3 of 5 (222 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
Posts: 761
Registered: ‎12-12-2006
Message 4 of 5 (216 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: 80
Registered: ‎07-29-2011
Message 5 of 5 (200 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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you interested in helping shape the Autodesk Community?
We’re looking at a few different ways to improve the “All Forums” landing page and need your feedback! If interested, please take a few minutes to fill out the following Usability Study. Thank you for your time!

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community