String strInsHandle = tools.getParamValue("InstanceHandle"); // pzInsKey of the Data-WorkAttach-File instance you want to open
String strFileSourceRef = "pyAttachStream";
Boolean boolIsBase64Encoded = true;
String strFileNameReference = tools.getParamValue("FileNameReference"); //File name, this is arbitrary but make sure you use the same when calling the parse excel activity.
Boolean boolPersistFileToServiceExport = true; // instructs the function to save file in the temp directory.
Boolean boolSendFileForDownload = false;
tools.sendFile(strInsHandle, strFileSourceRef, boolIsBase64Encoded, strFileNameReference, null, boolPersistFileToServiceExport, null, boolSendFileForDownload);
Set param.FSFileName = pxProcess.pxServiceExportPath + <<>>
Call pxParseExcelFile (or the MSOParseExcel in older versions of Pega). Remember to set param.bDeleteFile to true to ensure the temp file is deleted from the service export filepath.
@GayathriL since both out-of-the-box activities (MSOParseExcelFile and its successor pxParseExcelFile) require a file name and not a base64-encoded string, your options are somewhat limited. Depending on your use case you may find it easier to create an activity from scratch, either reusing Parse-XML rules - if you can expect Office Open XML files.
There may be another option to temporarily save a file from Data-WorkAttach-File, but I am not sure if this is appropriate.
Hi Joe, Thanks for the update and this seems to help me in parsing the file… But one issue what I see is.. the file gets downloaded after being parsed. How can I avoid it?
As per my requirement, I don’t want the file to be downloaded.
This is working for me, just create a temp page of class Data-Artifact to run it (or save as the activity to a different class, it has no dependencies on the class).
Then you can call pxParseExcelFile in the same way as before.
JoeH9464 solution worked for me, I tried in my local server.
As soon as you receive the file from another system , if it’s necessary to store the file you can store it in Data-Work-Attach-File / Pega-Social-Document (if you are using 8.x version) else you can run pxCreateFile (Data-Artifact) activity to store the file in static content directory for parsing.
Verified : Pega is storing created file in static directory
file://web:/StaticContent/global/ServiceExport/{filename}, you can form this path and pass it to either pxParseExcelFile/MSOParseExcelFile activity and make sure that you are passing true for bDeleteFile param as best practice after parsing the file, removing the file from StaticContent directory
@VinayKumarL16594575 Hi , we have a requirment to parse the excel that not only has rows but also some other data.May i know if we can create a template for this , if yes please provide a sample template.
Attaching a sample excel that we need to parse. Thanks in advance.