Klevr Product Documentation logo

Dynamic File Naming & Klevr Auto Number

This documentation outlines the functionality and configuration of a Portal upload enhancement and a Custom API that together enable dynamic file naming...

This documentation outlines the functionality and configuration of a Portal upload enhancement and a Custom API that together enable dynamic file naming and centralized tracking of uploaded attachments—whether stored in Blob or SharePoint.

🌐 Portal Upload: Dynamic File Naming

🔄 Purpose

Allow users to upload files with dynamically generated names based on:

  • Upload timestamp (datetime)
  • Original file name (originalname)
  • Any field from the associated entity (e.g., applicationid, contactname)
  • A global sequence number shared across all attachments

🧩 How It Works

  • In Umbraco you can change the AutoNumberFileName.
  • Supported slugs:
    • {dateTime} → Current timestamp
    • {dateOnly} → Current Date Only
    • {timeOnly } → Current Time Only
    • {originalFileName} → Original file name
    • {fieldname} → Field from the current entity
    • {autoNumber} → Global counter value
  • Example template: {autoNumber}-{originalFileName}-{dateTime}-{klevr_name}
  • On upload:
    • Slugs are resolved dynamically.
    • {autoNumber} is retrieved via the Custom API (see below).
    • Final file name is applied before storage.

⚙️ Custom API: Global Sequence Counter

🧠 Purpose

Maintain a single global counter for all uploaded attachments—regardless of storage type (Blob or SharePoint).

🔧 Implementation

  • Custom API Endpoint: Exposes a method to retrieve and increment the global counter.
  • Environment Variable: Stores the current counter value
  • Behavior:
    • On each upload, the API:
      1. Reads the current counter value.
      2. Increments it.
      3. Returns the updated value to the Portal for filename generation.
  • Storage-Agnostic: Works seamlessly with both Blob and SharePoint attachments.

✅ Benefits

  • Consistent Naming: Ensures predictable and traceable file names.
  • Centralized Tracking: One counter for all uploads simplifies auditing.
  • Flexible Templates: Admins can define naming logic using entity data.

Last updated on