How can I dynamically name PDF files created through Apsona merges, and what is the best way to mass rename existing documents already in Salesforce?

This requirement typically arises when organizations generate tax letters, receipts, or periodic statements using Apsona and need clearer, more descriptive PDF names, both for future merges and for large numbers of older files already attached to Person Accounts or visible in customer portals.

A complete solution involves two steps:
(1) setting up dynamic naming for newly generated files, and
(2) bulk updating the names of historical files already stored in Salesforce.

A. Dynamic Naming for Future Merges

Apsona supports custom file naming from within merge actions.

How to set it up:

  1. Add a Calculated Field
  • Create a JavaScript formula in your Apsona report
    (e.g., "Tax Letter " + new Date().getFullYear() + " – " + {{!Account Name}}).
  1. Configure the Merge Action
  • Open the Merge Action settings (Step 2).

  • Choose Field to use as file name.

  • Select the calculated field or any merge field producing the final filename.

All future PDFs generated by the merge will automatically adopt the custom naming format (e.g., Tax Letter 2024 – John Smith).

B. Mass Renaming Existing Files in Salesforce

Apsona can bulk update stored file names so legacy files match the new structure.

Process Overview:

  1. Determine File Storage Type
  • Classic → Attachment

  • Lightning → ContentVersion / ContentDocument

  1. Export Existing Files
  • Create a report or filter on the file object.

  • Export fields such as:

  • Record ID

  • Current File Name (Title / Name)

  • Parent record (Account / Person Account)

  1. Generate New File Names
  • Use Excel formulas to build new naming patterns
    (e.g., "Statement – March 2025 – " & AccountName).
  1. Bulk Update via Apsona
  • Use Import/Update mode

  • Operation: Update existing records

  • Map:

  • File ID → Salesforce Record ID

  • New file name → Title (ContentVersion) or Name (Attachment)

Running the update renames all files instantly without needing to download or re-upload them.

Key Takeaway

  • Future merges → Controlled via dynamic naming fields in the merge action

  • Existing files → Renamed in bulk using Apsona’s export + update workflow
    This ensures consistent naming conventions across historic and newly generated records—especially important when exposing documents in customer portals.