Extract and Insert Attachments Through JAVA API _ BMC Communities
Short Description
Extract and Insert Attachments Through JAVA API _ BMC Communities...
Description
10/15/2014
Extract and Insert Attachments through JAVA API | BMC Communities
Communities Products
Market Topics
bmc.com
Partners
User Groups
Customer Programs BMC.com > All Places > Products > BMC Atrium > BMC Remedy AR System > Discussions
Social Help BMC Social
YouTube Channel
search bmc.com
BMC Podcasts
9 Replies Latest reply: Apr 6, 2009 1:02 AM by kluu1
Lidiane.carvalho Nov 25, 2008 7:56 AM
Extract and Insert Attachments through JAVA API This question has been Answered. Hello, What is the way for extracting an attachment with the Java API 7.1, are there any examples? I need to extract an attachment from one server and insert another server. Can somebody help me? Thank you! Lidiane
5575 Views
Tags:
Appajee Papolu Nov 25, 2008 1:04 PM (in response to Lidiane.carvalho) 1. Re: Extract and Insert Attachments through JAVA API
Look at javadocs on ARServerUser.getEntryBLOB and ARServerUser.createEntry methods. Also look into JavaDriver sample source code to see the usage snippets. Appajee
Like (0)
Lidiane.carvalho Nov 25, 2008 2:19 PM (in response to Appajee Papolu) 2. Re: Extract and Insert Attachments through JAVA API
i can get file contents from attachment field with getEntryBLOB, but createEntry doesn't have a method to insert contents files.
Like (0)
John NameToUpdate Nov 25, 2008 2:47 PM (in response to Lidiane.carvalho) 3. Re: Extract and Insert Attachments through JAVA API
Here is some code that works:
Entry entry = getentry(aruser); // this does a query for the entry that is going to be modified. try
https://communities.bmc.com/message/84222#84222
1/4
10/15/2014
Extract and Insert Attachments through JAVA API | BMC Communities { AttachmentValue attachment = new AttachmentValue(attachmentName, filename) entry.put(FIELD_ID_CSV_ATTACHMENT, new Value(attachment)); String entryIdOut = aruser.mergeEntry(FORM_NAME, entry, Constants.AR_MERGE_ENTRY_DUP_MERGE); logger.info("Entry updated. The id # is " + entryIdOut); } catch (IOException e) { logger.error("Cannot attach file: " + filename, e ); } catch (ARException e) { logger.error("Cannot create the entry: ",e ); logger.error("cause: " + e.getMessage()); } John
Like (0)
Lidiane.carvalho Nov 25, 2008 6:10 PM (in response to John NameToUpdate) 4. Re: Extract and Insert Attachments through JAVA API
John, Thanks for answering my question!!! I tested your code on my project and I have a problem. In JAVA API 7.1 Constants.FIELD_ID_CSV_ATTACHMENT doesn't exists. Do you know a similar Constants? Tkssssss a lot !!!!
Like (0)
John NameToUpdate Nov 25, 2008 6:18 PM (in response to Lidiane.carvalho) 5. Re: Extract and Insert Attachments through JAVA API
Yeah.... hmmm.. This code is from the up comming 7.5 release. Sorry. So it might not work with the older java apis. There might not be an equivilent. I will try to find an equivilent. John
Like (0)
Gino Lorusso Nov 28, 2008 5:40 AM (in response to Lidiane.carvalho) 6. Re: Extract and Insert Attachments through JAVA API
Hi, you should add attachment object to the Entry object in order to create an entry with attachment. I have a sample for ARS 7.1 API but, of course, you need to code it better. Try with following lines (they are just an example):
String entryIdOut = ""; Entry entry = new Entry(); // attachment file name String aname = "attachment.txt"; // full local physical path to the attachment String filePath = "C:\\yourpath\\attachment.txt"; // Create an AttachmentValue object using the String above in the constructor
https://communities.bmc.com/message/84222#84222
2/4
10/15/2014
Extract and Insert Attachments through JAVA API | BMC Communities try { attach = new AttachmentValue(aname, filePath); } catch (Exception e) { System.out.println(e); } // add your fields to the entry object .... .... .... // Add the attachment field to the entry // lets assume that 536880912 is your attachment field id entry.put(536880912, new Value(attach)); entryIdOut = server.createEntry(formName, entry); System.out.println("Entry created. ID" + entryIdOut);
Like (0)
Lidiane.carvalho Nov 28, 2008 6:35 AM (in response to Gino Lorusso) 7. Re: Extract and Insert Attachments through JAVA API
Yesterday I did it and works fine !! Tks !!!
Like (0)
Appajee Papolu Feb 4, 2009 12:53 AM (in response to Lidiane.carvalho) 8. Re: Extract and Insert Attachments through JAVA API
While creating/modifying entry, you can set a field value to a specifc attachment value right then, just as you assign any other field values. Look at AttachmentValue class. Only the retrieval is a two step process (getEntry then getEntryBLOB). Appajee
Like (0)
kluu1 Apr 6, 2009 1:02 AM (in response to Gino Lorusso) 9. Re: Extract and Insert Attachments through JAVA API
Should just clarify that if you want to associate the attachment with an existing ticket, you should use the setEntry() call rather than createEntry()
Like (0)
Find People Support Login
Community Help Worldwide
About BMC
BMC.com
https://communities.bmc.com/message/84222#84222
0
Google +
0
0
0
New
3/4
10/15/2014
Extract and Insert Attachments through JAVA API | BMC Communities © Copyright 2005-2014 BMC Software, Inc. Use of this site signifies your acceptance of BMC's Terms of Use, Privacy Policy and Cookie Notice. BMC, BMC Software, the BMC logos, and other BMC marks are trademarks or registered trademarks of BMC Software, Inc. in the U.S. and/or certain other countries. Manage Cookies
https://communities.bmc.com/message/84222#84222
4/4
View more...
Comments