Skip to main content

Flow 1: Create Sales Calculator

This record-triggered flow fires when a new Opportunity is created. It checks the parent Account's Google Drive folder, creates a subfolder for the Opportunity, copies the Sales Calculator template into it, and stores the references back on the Opportunity.

Complete Sales Calculator creation flow

Create the Flow

  1. Go to Setup > Flows > New Flow.
  2. Select Record-Triggered Flow.
  3. Configure the trigger:
    • Object: Opportunity
    • Trigger the flow when: A record is created
    • Optimize the flow for: Actions and Related Records
  4. Under Run Asynchronously, add a scheduled path with Run Asynchronously set to immediately after the record is saved.

Check If the Account Has a Google Drive Folder

  1. Add a Decision element on the async path:
    • Label: Account Has GDrive Folder?
    • Outcome "Yes": {!$Record.Account.GDriveFolderId__c} is null = False
    • Default Outcome: "No Folder" (flow ends)

Decision - Account Has GDrive Folder

Create the Opportunity Folder

  1. On the "Yes" path, add an Action element:
    • Action: Create folder - Simple Response Structure (DriveMate)
    • Folder Name: a formula "Opportunity - " + {!$Record.Name}
    • Parent Folder Id: {!$Record.Account.GDriveFolderId__c}
    • Label: Create Opportunity Folder
    • Store outputs automatically.

Create Opportunity Folder action configuration

Copy the Template Spreadsheet

  1. Create a formula resource:

SpreadsheetTitle (Text):

{!$Record.Name} + " - Sales Calculator"
  1. Add an Action element:
    • Action: Copy File (DriveMate)
    • File Id: the ID of your Sales Calculator template spreadsheet
    • New File Name: {!SpreadsheetTitle}
    • Destination Folder Id: {!Create_Opportunity_Folder.folderId}
    • Label: Create Sales Calculator - Copy Template
    • Store outputs automatically.

Copy File action configuration

Where to find the template ID

Open your template spreadsheet in Google Sheets. The spreadsheet ID is the long string in the URL between /d/ and /edit - for example, in https://docs.google.com/spreadsheets/d/1Abc123xyz/edit, the ID is 1Abc123xyz.

Save References and Refresh the Component

  1. Add an Update Records element:
    • Record: the triggering Opportunity
    • Set fields:
      • GDriveFolderId__c = {!Create_Opportunity_Folder.folderId}
      • SalesCalculatorSpreadsheetId__c = {!Create_Sales_Calculator_Copy_Template.fileId}

Update Opportunity with folder and spreadsheet IDs

  1. Add an Action element:
    • Action: Refresh DriveMate Component (DriveMate)
    • Related Record Id: {!$Record.Id}

Refresh DriveMate Component action

  1. Save the flow as Sales Calculator: Create After Opportunity Creation and Activate it.