Topic Options
Rate This Topic
#134059 - 03/22/06 06:01 AM .Net API - Retrieve Attachments
sheider162 Offline
enthusiast

Registered: 05/01/05
Posts: 226
**
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

Top
#134060 - 03/22/06 07:03 AM Re: .Net API - Retrieve Attachments [Re: niklas_asplund442]
appajee_papolu935 Offline
newbie

Registered: 03/10/05
Posts: 21
**

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

Top
#134061 - 03/22/06 07:11 AM Re: .Net API - Retrieve Attachments [Re: niklas_asplund442]
tim_widowfield Offline
journeyman
*****

Registered: 11/04/05
Posts: 51
I'm not a VB expert (thank the gods), but I *think* you still have to use the
right case in methods. If so, it's GetEntryBLOB(). There's a simple example
in the CHM doc file for .NET. It goes like this:

Dim entryIdList
Set entryIdList = CreateObject("ARSystem.EntryIdList")
entryIdList.FromString "000000000000001"
Dim bytes
Set bytes = server.GetEntryBLOB(formName, entryIdList, 536880912)

--Tim


--- "Papolu, Appajee" wrote:

> 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 = "> {System.IndexOutOfRangeException} occurred>"
>
>
>
>
>
> Stephen
>
> 20060125This posting was submitted with HTML in
> it
>
>

> UNSUBSCRIBE or access ARSlist Archives at http://www.ARSLIST.org
>


UNSUBSCRIBE or access ARSlist Archives at http://www.ARSLIST.org

Top