Question
HCL
IN
Last activity: 5 Jul 2017 13:40 EDT
How to attach a PDF from server path to Work Object?
How to attach a PDF from server path to Work Object? How to implement this? Pega v7.1.8
Please provide ur inputs. Thanks in advance.
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Pegasystems Inc.
IN
Hi
Have you explored this How to article ? https://community.pega.com/how-create-activities-attach-files-work-objects
HCL
IN
Thanks santhanu.
But that article deals with binary file path.
But my flat PDF file is placed in server location ("../test11.pdf").
I tried below java code. This helps me to down load the file from server location. But i am not able to attach that to work object.
if you have any java code to attach the document from server path it will be helpful.
/*The File Path along with the name to download need to be mentioned here */
String filePath = tools.getParamValue("FilePath");
java.io.FileInputStream fileInputStream=null;
java.io.File file = new java.io.File(filePath);
byte[] bFile = new byte[(int) file.length()];
try {
fileInputStream = new java.io.FileInputStream(file);
fileInputStream.read(bFile);
fileInputStream.close();
}
catch(Exception e){
e.printStackTrace();
}
/* Change the name of the Test.docx to the actual file name that needs to be downloaded with extension.*/
String sErrorMessage = tools.sendFile(bFile, "Test.docx", false, null, true);
if (sErrorMessage != null){
tools.getThread().getThreadPage().putString("pyXMLStream", sErrorMessage);
}
Updated: 1 Feb 2016 8:56 EST
Virtusa IT Consulting
AE
Hi Antony,
What Santanu Bhattacherjee has suggested is to use activities to attach the files, in the article as an example 'Rule-File-Binary' is mentioned; similarly you can use 'Rule-File-Text', 'Rule-File-eForm' etc.
However 'Rule-File-Binary' is more generic to use for storing files of any file type. You need to follow steps as below.
- Create a page for the work object attachment (Data-WorkAttach-File class).
- Put the file on the attachment page.
- Save the attachment page (Obj-Save method).
- Create a link object (Link-Attachment class) that connects the attachment to the work object with the Link-Objects method.
Thanks,
Habeeb Baig
Virtusa IT Consulting
AE
are you trying to fetch the file from a relative path of your server or a direct path?
HCL
IN
its relative path
Tata Consultancy Services
US
How did you get the filepath of the server?