Attach incoming excel file to existing case based on file name

Hi, we have a plan to process incoming excel file via file listener (file will be present in a repository folder). The file will have a name of the case ID and it should attach to the existing case.

We have the file listener working, however are hitting bit of problem with the ServiceFile processing and finding the file name to pickup. Cannot figure out what is the correct way to have Request and Method tab.

Can you please advise how to achieve this processing?
Also the excel should then be attached to the existing case => assuming here we have to copy the file from the inbound repository folder to attachments folder.

Thank you in advance.

For your scenario, do not treat the Excel workbook as normal row-by-row delimited data. Configure the Service File to receive the workbook as a single binary/base64 payload, extract the case ID from the file name, open that case, and create a Data-WorkAttach-File attachment. The File Listener itself moves eligible files into its work_<listener> directory and invokes the Service File rule; it does not normally expose the original filename as a parseable field.

Use this flow-

  • External system drops C-123.xlsx into the watched folder.
  • File Listener matches *.xlsx and moves it to its work_<listener> folder.
  • Service File rule reads the workbook as a whole file.
  • Service Activity obtains the source filename, parses C-123, opens the case, and attaches the Excel content.
  • On success, the listener moves the source file to Completed. On failure, configure error handling so it is retained or moved to an error folder.

Avoid copying the file manually from the inbound repository folder to an attachments folder. Pega attachments should be represented as Data-WorkAttach-File instances linked to the case. depending on your attachment storage configuration, Pega stores either the file content or a repository/web-storage reference.

Service File Configuration:

The Service File rule parses the input according to its Request and Method tabs and then calls the configured Service Activity. For an Excel file, use a binary request type rather than CSV/delimited parsing and configure to parse the complete file content into one property.

Then, in the Service Activity, retrieve the original filename from the listener context and you can use a simple function as

@substring(param.FileName, 0, @lastIndexOf(param.FileName, "."))

Hi Ravi,
I’m bit stuck on the “use binary only” in the service file, but then I do not have any idea what to use in Request map to field. I cannot use Clipboard, Skip any of the parse things, and I cannot leave it empty as it is required field.
I have now tried it with text only and “Skip” map to and use the Log Service File name pull.
It contains
pyOriginalFileName => HAT-0001-29OCT26_HappyHalloweenyt_20260102.xlsx
pyBytesProcessed=> 0
pyFileLength=> 9754

Unfortunately, at the moment I cannot pull the name via the Log Service File.
Any idea on what you meant by the “binary request type” ?
Thank you again.

@RenataC5 When configuring a Service File rule to ingest binary files like Excel spreadsheets, selecting “Use binary only” tells Pega to treat the incoming payload as a raw binary stream (ClipboardProperty of type Java Object or stream reference) instead of trying to parse it as text, XML, or record-delimited lines. Because of this standard text parsing options and direct property mapping on the Request tab do not apply. you can use Skip map-to configuration on the Request tab and capture the raw stream or file reference directly inside your service activity.

Filename in yout processing Activity should be available as part of your Parameter page (Param.pyFileName) or your primary Service Activity’s primary page, which you define it in the service tab. You can run the tracer and verify the Service File/ Param page to check the initial page when the service file is initialised.

Method Tab

This is where I’m actually getting stuck. The moment I use the “binary only”, Pega does not allow me (v26) use the “Skip” in the Request tab
I get the below error:
This record has 2 error(s) in 2 place(s) .

Data mode—

Skip only valid for text only data streams.

What action are we taking in this parse step.—

Skip only valid for text only data streams.

Do you have experience using the Skip with binary only and it working?
Thank you.

@RenataC5
can you try the solution mentioned in this thread?
Instead of the binary file, when the file processed via FileListener, the file name is stored as part of ‘LogServiceFile.pyOriginalFileName’, where ‘LogServiceFile’ is of class ‘Log-Service-File’

it worked to pass the name and extract it like this. Thank you greatly.

unfortunately what is not working at the moment is the file attaching, the content is basically being lost during the move from sftp/inbound to the work_Listener and then the GetFile data page cannot extract it to pass into the case.

with this specific error:
Unable to open an instance using the given inputs: pxObjClass = “Rule-ClassMetadata”, pyClassName = “Embed-Repository-File”