👷🔧 Storyforce is under early construction, many pages are half finished! 🔧👷
Playbook
Process Automation
Flows
Content Document Link

Content Document Link Flows

Add Quote Files to Opportunity

Design

This is most commoonly used to copy a DocuSign file from a Quote to an Opportunity

User Story
As a Salesforce User
I want all files related to a Quote to be visible on the parent Opportunity
So that I can easily view the files from the Opportunity record without having to navigate to the Quote record
Acceptance Criteria
Given I am on a Quote record page
When I upload a file to the Quote
Then the file is visible on the parent Opportunity record

Build

At the time of writing in June 2024 Flows can NOT be triggered by Content Document Link creation, as a workaround you can use an Apex Trigger to call a Flow when a new Content Document Link is created

To-do:

  • Create a Flow to update the Opportunity with the Content Document Link
  • Create a Apex Trigger to call a flow when a new Content Document Link is created

Flow

Flow Type: Autolaunched Flow (No Trigger)
Flow Label: CDL: Add Quote CDL to Opp
Flow API Name: CDL_Add_Quote_CDL_to_Opp
Description: Updates the Opportunity with the Content Document Link from the Quote.

Recosource Type: Variable
API Name: recordId
Data Type: Text
available for input: checked
The recordID is the Id of the Content Document Link that was created and is being passed to the flow via the Apex Trigger.

  1. Element: Get Records
    Label: Get Content Document Link
    Object: Content Document Link
    Conditions:
    • Id -> Equals -> {!recordId}
  2. Element: Decision
    Label: Linked Entity is Quote?
    Outcome 1:
    • Label: Yes - Quote
    • Condition: {!Get_Content_Document_Link.LinkedEntityId} Starts With 0Q0
      Quotes have an Id that starts with 0Q0, this can be verified by checking the Id of a Quote record in the URL.
  3. Element: Get Records
    Label: Get Quote
    Object: Quote
    Conditions:
    • Id -> Equals -> {!Get_Content_Document_Link.LinkedEntityId}
  4. Element: Create Records
    Label: Create CDL for Opportunity
    Object: Content Document Link
    Set Field Values: - Linked Entity Id = {!Get_Quote.OpportunityId} - Content Document Id = {!Get_Content_Document_Link.ContentDocumentId} Content Document Link Quot to Opportunity Flow

Create Apex Trigger

Apex Trigger can only be created in a Salesforce Developer Edition or a Salesforce Sandbox. It cannot be created in a Salesforce Production org.

Trigger Name: ContentDocumentLinkTrigger
Object: ContentDocumentLink
Trigger Code:

trigger ContentDocumentLinkTrigger on ContentDocumentLink (after insert) {
 
    for (ContentDocumentLink cdl : Trigger.new) {
        // Create a map to hold the flow inputs
        Map<String, Object> flowInputs = new Map<String, Object>();
        flowInputs.put('recordId', cdl.Id);
 
        try {
            // Create and start the flow interview
            Flow.Interview.CDL_Add_Quote_CDL_to_Opp flowInterview = new Flow.Interview.CDL_Add_Quote_CDL_to_Opp(flowInputs);
            flowInterview.start();
        } catch (Exception e) {
            System.debug('Exception: ' + e.getMessage());
        }
    }
}

Test

Steps

  1. Open a Quote record page
  2. Upload a file to the Quote
  3. Verify the file is visible on the parent Opportunity record

Expected Results

  1. The file is visible on the parent Opportunity record

Add Only DocuSign Files to Opportunity

This flow is a variation of the previous flow, it simply adds a DocuSign filter.

Design

User Story
As a Salesforce User
I want all DocuSign files related to a Quote to be visible on the parent Opportunity
So that I can easily view the DocuSign files from the Opportunity record without having to navigate to the Quote record
Acceptance Criteria
Given I am on a Quote record page
When I upload a DocuSign file to the Quote
Then the DocuSign file is visible on the parent Opportunity record

Build

Create a flow as shown above Content Document Link Flows

Amend the Decision element to check if the file is a DocuSign file

Element: Decision
Label: Linked Entity is Quote?
Outcome 1: Label: Yes - Quote Conditions:

  • {!Get_Content_Document_Link.LinkedEntityId} -> Starts With -> 0Q0
    Quotes have an Id that starts with 0Q0, this can be verified by checking the Id of a Quote record in the URL.
  • {!Get_Content_Document_Link.ContentDocument.Title} -> Contains -> DocuSign \

Test

Steps

  1. Open a Quote record page
  2. Upload a DocuSign file to the Quote
  3. Verify the DocuSign file is visible on the parent Opportunity record
  4. Upload a non-DocuSign file to the Quote
  5. Verify the non-DocuSign file is NOT visible on the parent Opportunity record

Expected Results

  1. The DocuSign file is visible on the parent Opportunity record
  2. The non-DocuSign file is NOT visible on the parent Opportunity record Content Document Link Quot to Opportunity Flow