Java call to extract attachments from Remedy

The most efficient way to extract files from a Remedy database is to use the Java API library shipped with Remedy.  The Java API from BMC Software is a collection of classes, interfaces, and relationships that provide full client functionality like the AR System C API in a style consistent with typical Java programming techniques. Like the C API, the Java API is forward and backward compatible with other versions of AR System. Consistent with object-oriented design, the AR System Java API represents AR System server objects as Java objects. Classes are defined for forms, fields, menus, active link, filter, escalations, and all other objects in an AR System application. Entry objects represent entries (requests) so your Java client can manipulate AR System data as well as definitions. [1]  The full java reference library is installed with the ARSystem server and is typically stored  C:\Program Files\BMC Software\…. \arserver\api\doc. You can view the library with your browser or copy the ardoc*.jar file to your desktop and rename it to ardoc*.zip.

Below is a sample of code using an AR Java call, getEntryBlob.  As the program name says, GetAttachmentFromRemedy uses a set of user defined inputs to extract an attachment file from a Remedy database.  It then takes the file and places it in a user defined directory on the Remedy application server.

Before using this code on your installation, check if the version of jar file has changed.  In some cases the AR Java calls have been rewritten and therefore use different parameters.  It is recommended to use the version installed you’re your Remedy application.

This code was written on an Eclipse editor and was later compiled using launch4j to create an .exe file.  It is not necessary to have an .exe file but it is clean and easier to transport.


//GetAttachmentFromRemedy ARS 7.6.04 v1.0

Required: Remedy account w/read license and no group assignment. Login: jschmoe Password: remedy

The source code below is the source code for ARS 7.6.04

Create an executable .jar file using Eclipse then test.  Create executable .exe with launch4j using the .jar file.

The directory structure and files used:

D:\Program Files\BMC Software\ARSystem\Arserver\api\Code



D:\Program Files\BMC Software\ARSystem\Arserver\api\Code\remedyAPI

D:\Program Files\BMC Software\ARSystem\Arserver\api\Code\remedyAPI\src



D:\Program Files\BMC Software\ARSystem\Arserver\api\Code\remedyAPI\bin




Example test

–   must have corresponding Attachment File in Remedy

–   Can be of any file type e.g. .doc, .pdf, .csv, etc.

D:\Program Files\BMC Software\ARSystem\Arserver\api\Code\remedyAPI\bin>

GetAttachmentFromRemedy.exe <login> <password> <server> <formRecordID> <directoryPathOnServerWhereFileWillBePlaced> <nameOfFileToBeExtracted> <statusOfFormRecord> <fieldIDOfAttachmentFile>

D:\Program Files\BMC Software\ARSystem\Arserver\api\Code\remedyAPI\bin>

GetAttachmentFromRemedy.exe jschmoe remedy remedyServer-02 “INC000000000212” “D:\\AttachmentFolder\\FirstSet\\TestData\\” “BMC ARS Service Pack Upgrade – 206292.pdf” “New” “600017101”




import com.bmc.arsys.api.*;


//import java.text.SimpleDateFormat;

//import java.util.Date;

// GetAttachmenFromRemedy version for ARS 7.6.04  v1.o

publicclass  GetAttachmentFromRemedy{


publicstaticvoid main(String[] args) {



BufferedWriter out = null;


// Create file

FileWriter fstream = new FileWriter(“D:\\CDRL\\TestFileName.txt”);

out = new BufferedWriter(fstream);

//Close the output stream

System.out.print(args[0] + ‘\n’);

System.out.print(args[1] + ‘\n’);

System.out.print(args[2] + ‘\n’);

System.out.print(args[3] + ‘\n’);

System.out.print(args[4] + ‘\n’);

System.out.print(args[5] + ‘\n’);

System.out.print(args[6] + ‘\n’);

System.out.print(args[7] + ‘\n’);


}catch (Exception e){//Catch exception if any

System.err.println(“Error: ” + e.getMessage());



// Username to login to ARServer

String uname = args[0];

// Password for the User

String pword = args[1];

// Authentication String

String auth = “”;

// Local

String local = “”;

// ARServer

String serv = args[2];

// Port

int port = 12345;

// Create ARServerUser object with supporting information.

ARServerUser Login = new ARServerUser(uname, pword, auth, local, serv, port);

// Form name you wish to retrieve the attachment from in the constructor.

String formName = “ARSCustomHelpDesk”;

// EntryID of the record you wish to retrieve the attachment from in the constructor

String entryID = args[3];

// fieldID of the attachment field in the constructor

int fieldID = Integer.parseInt(args[7]);

//SimpleDateFormat FormattedDate = new SimpleDateFormat(“MMddyy”);

String strDirectory = “”;

//  **  Create a new directory


strDirectory = args[4]+ “\\” + args[3] + “\\” + args[6] + “\\”;

// Create one directory

(new File(strDirectory)).mkdirs();

}catch (Exception e){//Catch exception if any

System.err.println(“Error: ” + e.getMessage());


//  **  END

// Need to have the Login.GetEntryBlob() method in a try block to catch ARException

// Set a string variable for the name of the attachment

String aname = args[5];

aname = aname.substring(aname.lastIndexOf(‘\\’)+ 1);

// Set a string variable for the full path of where you wish to copy the attachment to.

String filePath = strDirectory + aname;


// Call getEntryBlob with supporting information

//void ARServerUser.getEntryBlob(String formName, String  entryID, int fieldID, String filePath)

Login.getEntryBlob(formName, entryID, fieldID, filePath);


}catch (Exception e){//Catch exception if any

System.err.println(“Error: ” + e.getMessage());





This code can be called from Remedy workflow and is reusable as most of the inputs are user defined variables.  I called this program from a filter guide where up to 12 attachment fields were listed on a custom form.


BMC, BMC Software, and the BMC Software logo are the exclusive properties of BMC Software, Inc., are registered with the U.S. Patent and Trademark Office, and may be registered or pending registration in other countries. All other BMC trademarks, service marks, and logos may be registered or pending registration in the U.S. or in other countries. All other trademarks or registered trademarks are the property of their respective owners.
Java is a trademark of Oracle Corporation