how to capture only file data from upload file function in pega

Hi All,

I have a requirement that I need to generate a report and need to attach generated excel report in the email, for that we are using pxGenerateExcelFile OOTB activity to generate a excel file, after that we need to attach the excel in the mail, so I am using @uploadFile() function to get the encoded string of excel file.

The function returning FilePath,FileName,FileExtension and FileData, but I need only FileData for sending email notification.

I have tried whatcomesafterlast to get the only Filedata and also tried replaceall function to replace other fields with null, but none is working with encoded string.

Is there a way to get only filedata from uploadfile function?

@VeerendraC Refer pyActionSendMail activity and its helpful for your requirement.

@Nadimuthu T Thank you for your response, I have gone thorough the activity pyActionSendMail, We have also implemented similar steps with reportdefinition to create a page list and pxGenerateExcelFile activity, Where as we have used same java step in our activity what is present in pyActionSendMail.

My logic is working obsoletely but the concern is java step, we have been asked to avaoid java step, that is the reason we are going with @uploadFile() function to get the encoded string of excel file but the function returning FilePath,FileName,FileExtension and FileData, but I need only FileData for sending email notification.

@VeerendraC16933361
Did you find any solution to get encoded base64 stream from the output string of @uploadFile()

@bogga unfortunately No, We couldn’t use this function to get only file data, we have created custom function to achieve the same requirement.

@VeerendraC16933361

Updating the solution here so that it can be useful for others.

The reason we are not able to use string functions like @whatcomesafterlast, @replaceall,… is uploadFile() returns a hashmap object which contains data in key value pairs fashion.

Though a param variable is able to reference this hashmap object contents in tracer, string library functions cannot be used as this is a java object.

Using below code snippet, the hashmap object can be converted into string using typecasting.

//assuming pxRequestor.pyFileUpload contains the file path/directory location

//Eg of pxRequestor.pyFileUpload = file://web:/StaticContent/global/ServiceExport/sample.csv

Custom GetFileDetails() definition:

PublicAPI tools = (PublicAPI) ThreadContainer.get().getPublicAPI();

java.util.HashMap hmFileInfo = pega_rules_utilities.uploadFile();

String FileData = (String)hmFileInfo.get(“FileData”);

tools.getParameterPage().putString(“FileStream”,FileData);