We have successfully generated an Excel output file using pxGenerateExcelFile activity.
Now, how/where can we get the file content stream?
We have to attach the output file to an email and send. No work object is involved.
Thanks in advance.
We have successfully generated an Excel output file using pxGenerateExcelFile activity.
Now, how/where can we get the file content stream?
We have to attach the output file to an email and send. No work object is involved.
Thanks in advance.
@Will Cho I used this Java code to get the byte stream of excel file generated.
Video reference - https://www.youtube.com/watch?v=w1IYdF8o17E
String strFileName = tools.getParamValue(“OutputLocation”);
PRFile objFile = new PRFile(strFileName);
//some error checking
if (!objFile.exists())
{
attach = false;
}
if(!objFile.isFile())
{
attach = false;
}
tools.putParamValue(“OutputLocation”, objFile.getName());
if (!objFile.canRead())
{
attach = false;
throw new PRRuntimeException(“Can’t continue with file upload. File "” + strFileName + “" is unreadable.”);
}
//read the file into a buffer.
java.io.DataInputStream dis = null;
byte buffer = null;
try
{
dis = new java.io.DataInputStream(new PRInputStream(objFile));
buffer= new byte[dis.available()];
dis.readFully(buffer);
dis.close();
}
catch (Exception e)
{
attach = false;
throw new PRRuntimeException(“Can’t continue with file upload. Can’t read File "” + strFileName + “"”);
}
//encode the file to Base64 so that we can store it on the database
strFileData = Base64Util.encodeToString(buffer);
if (strFileData == null)
{
attach = false;
throw new PRRuntimeException(“Can’t continue with file upload. Couldn’t encode the file to Base64 so that we can store it on the database”);
}
Email sent successful:
@Will Cho can you please let me know how you have attached this file to the email? The OOTB activities ask for attachment category and based on category attachments from the case will get attached to the email being sent. Here in your scenario I think you don’t have case, so attaching the attachments after converting it from stream, that process can you let me know?