**
Stephen,
GetListEntryWithFields just gets the attachment detail (like the attachment name etc; not the blob value itself). To retrieve the blob part, you need to make a separate call ARSystem.Server.GetEntryBlob() and save thusly retrieved blob value into a file.
If you know upfront which your attachment field is, then you can remove it from GetListEntryWithFields call (if this call were to be made any ways); simply call an additional GetEntryBlob call; If you don't know about which field might be an attachment field, then depending on the values retrieved from GetListEntryWithFields - if you bump into an attachment type value, then conditionally make an additional GetEntryBlob call for that specific field again.
Regards
Appajee Papolu
From: Action Request System discussion list(ARSList) [mailto:arslist@ARSLIST.ORG] On Behalf Of Heider, Stephen
Sent: Wednesday, March 22, 2006 10:01 AM
To: arslist@ARSLIST.ORG
Subject: .Net API - Retrieve Attachments
ARS 6.3
.Net API (June 2005)
VB.Net 2003
I am trying to retrieve an attachment from a Remedy form. I can retrieve the attachment field but the Bytes list is empty. I must be missing something. It is possible to extract attachments from Remedy via the .Net API, correct?
Only one record will ever be returned, and only one attachment field. Here is the code:
Dim aFieldNos(0) As Integer
aFieldNos(0) = 2000012
Dim oFieldValueList As New ARSystem.EntryListFieldValueList
oFieldValueList = Remedy.RemedyServer.GetListEntryWithFields(FormName, "'Request ID' = " & """" & RequestID & """", aFieldNos, Convert.ToUInt32(0), Convert.ToUInt32(1))
For Each oListFields As ARSystem.EntryListFieldValue In oFieldValueList
For Each ARFieldNo As UInt32 In oListFields.FieldValues.Fields
Dim ARAttachment As New ARSystem.Attachment
ARAttachment = CType(oListFields.FieldValues(ARFieldNo), ARSystem.Attachment)
ARAttachment.Bytes.SaveToFile("c:\temp\MyFileAttachment.zip")
'Error: "Index was outside the bounds of the array."
Next
Next
Values at time of error:
FieldValueList.Count = 1
ListFields.EntryId.ToString = correct Request ID.
ListFields.FieldValues.Fields.Count = 1
ARAttachment.Bytes.Bytes = ""
Stephen
20060125This posting was submitted with HTML in it 20060125This posting was submitted with HTML in it