Skip to content

Flow Name: Downloadable Product File Sharing Logic

Last Updated: 2025-10-22 Source Code: Downloadable_Product_File_Sharing_Logic.flow-meta.xml

API Name: Downloadable_Product_File_Sharing_Logic Status: Active Type: Custom Trigger: Record-Triggered Flow - After Update on Product2

Business Purpose

This flow automates the creation of publicly accessible download links for digital products by generating Salesforce Content Distribution records and updating product records with the generated download URLs. It streamlines the process of making product files available to customers for download.

Process Flow

  • Gets the ContentDocumentLink associated with the product record
  • Uses the product's ID to find linked content documents

2. Content Availability Check

  • Decision: "Check if the content document Link exist"
  • Verifies that a ContentDocumentLink exists for the product
  • If no content document exists, flow ends

3. Content Version Retrieval

  • Looks up the ContentVersion record using the ContentDocumentId
  • Gets the first matching ContentVersion record

4. Content Distribution Creation

  • Creates a ContentDistribution record with the following settings:
  • ContentVersionId: From the retrieved ContentVersion
  • Name: Uses the ContentVersion title
  • PreferencesAllowOriginalDownload: true
  • PreferencesAllowPDFDownload: false
  • PreferencesAllowViewInBrowser: true
  • PreferencesExpires: false
  • PreferencesLinkLatestVersion: true
  • PreferencesNotifyOnVisit: false
  • PreferencesNotifyRndtnComplete: false
  • PreferencesPasswordRequired: false

5. Content Distribution Retrieval

  • Retrieves the created ContentDistribution record to get the public URL

6. Product Update

  • Updates the Product2 record with the DistributionPublicUrl
  • Sets the Product_Download_Url__c field with the generated public URL
📊 Click to view Process Flow Diagram
flowchart TD
    Start([Start: Product Updated<br/>IsDownloadableProduct = true<br/>Download URL is null]) --> GetLink[Get ContentDocumentLink<br/>for Product]

    GetLink --> CheckLink{Content<br/>Link Found?}
    CheckLink -->|No| End([End])
    CheckLink -->|Yes| GetVersion[Get ContentVersion<br/>Record]

    GetVersion --> CreateDist[Create ContentDistribution<br/>with Public URL Settings]
    CreateDist --> GetDist[Retrieve Created<br/>ContentDistribution]

    GetDist --> UpdateProd[Update Product2<br/>Product_Download_Url__c]
    UpdateProd --> End

    CreateDist -->|Error| ShowError[Display Error Message<br/>with Fault Details]
    ShowError --> End

    style Start fill:#e1f5ff
    style GetLink fill:#f0e1ff
    style CheckLink fill:#fff4e1
    style GetVersion fill:#f0e1ff
    style CreateDist fill:#ffe1e1
    style GetDist fill:#f0e1ff
    style UpdateProd fill:#ffe1e1
    style ShowError fill:#ffcccc
    style End fill:#e1f5ff

Key Business Rules

  • Only processes products where IsDownloadableProduct__c = true
  • Only processes products where Product_Download_Url__c is null (no existing URL)
  • Creates non-expiring public download links
  • Allows original file downloads and browser viewing
  • Disables PDF downloads, password protection, and visitor notifications
  • Links to the latest version of the file automatically

Dependencies

  • Product2 object with custom fields:
  • IsDownloadableProduct__c (checkbox)
  • Product_Download_Url__c (text field for storing URL)
  • ContentDocumentLink and ContentVersion objects
  • ContentDistribution object for file sharing
  • Salesforce Files and Content Management functionality

Changes

No specific changes or pull requests noted in the flow metadata.

Pre-Go-Live Concerns

CRITICAL - Fix Before Go-Live

  • None identified

HIGH - Address Soon After Go-Live

  • Add validation to ensure ContentVersion exists before creating ContentDistribution
  • Implement retry logic for failed ContentDistribution creation

MEDIUM - Future Enhancement

  • Consider adding expiration dates for security-sensitive files
  • Add notification mechanism for administrators when distributions are created
  • Implement audit logging for tracking when download URLs are generated

LOW - Monitor

  • Monitor ContentDistribution creation success rates
  • Track products that have files attached but no ContentDocumentLink
  • Verify that public URLs remain accessible over time

Maintenance Notes

  • Flow has basic error handling that displays fault messages to users
  • Only processes products during update operations, not on insert
  • Variables used: contentDistributionId (String) for storing distribution record ID
  • Complexity: Medium - involves multiple Salesforce Content objects and relationships
  • Review quarterly to ensure ContentDistribution settings align with security requirements