Close popover
Sonkar das (Sonkard5)
Infosys Ltd

Infosys Ltd
Sonkard5 Member since 2019 3 posts
Infosys Ltd
Posted: October 30, 2019
Last activity: October 30, 2019

Issue with Pdf attachment to the created cases

Business requirement:

Attaching pdfs to the created cases.

Descriptions: Pega is getting two types of files in the Pega cloud folder location with the same name one is pdf and another one is csv, using the csv files details Pega is creating the case and attaching the pdf of the same name (with only difference in file extension).

Using file listener to reads the csv and create the case, and below is the java code i am using to attach the pdf to the case.


Modifying the csv file as processed by file listener by getting it from Log-Service-File with pdf file extension like TestPdfSample.csv withTestPdfSample.pdf


Observations: 1. The functionalities are working fine and everything is working as expected in Dev environment(case creation and attachment of pdf).

2. The same functionalities are working fine for most of the files in Prod environment, but the pdf attachment is not happening for only very few cases.

I could not figure out the reason of its occurance as it is not that frequent in nature and the same code is working fine for most of the files(includes pdf and csv).

Note: The pdf files are correct only which Pega is getting and tested with the same files(which are causing issues in Production) in Dev env manually, and observed the functionalities are working as expected.

Could anyone help me here with the possible reason of this issue.


Java Code to attach the pdf into the case

byte buffer [] = null;
String strFileData = null;
// FilePath includes file location and file name
String strFilePath = FilePath; (Get the pdf file from Pega cloud server file location like /usr/Abc/TestPdfSample.pdf) fileName = null; fos = null;
//read the file into a buffer.
fileName = new;
fos = new; dis = new;
buffer = new byte[dis.available()];
catch (Exception e)
tools.getThread().getThreadPage().putString("pyXMLStream", "Can't continue with file attachment. Can't read File is unreadable."+e.getMessage());
nextBlock = "Err";
//encode the file to Base64 so that we can store it on the database
{ inByteStream = new; inStream = new; outByteStream = new; outStream = new; encStream = Base64Util.createEncodingOutputStream(outStream); doStream = new;
byte[] buffer2 = new byte[4096];
int len;
while(( len = != -1)
doStream.write(buffer2, 0, len);
strFileData = outByteStream.toString();
ClipboardPage cpNFAttach = tools.findPage("AttachmentPage", false);
cpNFAttach.putString("pyAttachStream", strFileData);
cpNFAttach.putString("pxAttachName", FName); // FName is the file name here(like TestPdfSample.pdf)
//cpNFAttach.putString("pyNote", strFilePath);
// close the fos and delete the file
catch (Exception e)
tools.putParamValue("ErrorBuffer", e.toString() + " " + e.getMessage());
nextBlock = "Err";

Pega Version:8.1.5 cloud instance

Thanks in Advance

Cloud Services
Moderation Team has archived post,
Close popover This thread is closed to future replies. Content and links will no longer be updated. If you have the same/similar Question, please write a new Question.