Ad Code

✨🎆 Diwali Dhamaka Offer! 🎆✨

Get 20% OFF on All Courses at Shiva Concept Solution click

Record-Triggered Flow in Salesforce

 

Example 1: Record-Triggered Flow



Goal: When an Opportunity is moved to Closed Won, automatically (1) create a follow-up Task for the owner and (2) set the related Account’s Customer Status to Active.

1) Create the flow

  1. Go to Setup → Process Automation → Flows → New Flow.

  2. Choose Record-Triggered FlowCreate.

  3. Object: Opportunity

  4. Trigger: “A record is updated

  5. Entry Conditions:

    • StageName Equals Closed Won

  6. When to Run the Flow for Updated Records: Only when a record is updated to meet the condition requirements (prevents repeated runs).

  7. Optimize the Flow For: Actions and Related Records (After Save) (needed because we’ll create a Task and update an Account).

Click Done.

2) (Optional) Add a formula resource for due date

  1. In the Manager tab → New Resource.

  2. Resource Type: Formula | Data Type: Date

  3. API Name: FollowUpDueDate

  4. Formula: TODAY() + 3
    Click Done.

3) Create the follow-up Task

  1. Drag Create Records onto the canvas.

  2. Label: Create Follow-Up Task

  3. How Many Records to Create: One

  4. How to Set the Fields: Use separate resources, and literal values

  5. Set fields:

    • Subject: Welcome / Kickoff call

    • Status: Not Started

    • Priority: Normal

    • OwnerId: {!$Record.OwnerId}

    • WhatId: {!$Record.Id} (relates the task to the Opportunity)

    • ActivityDate (Due Date): {!FollowUpDueDate} (or choose a static date offset if you skip the formula)

    • Description: Auto-created when Opportunity moved to Closed Won.

Click Done.

4) Update the related Account

  1. Drag Update Records onto the canvas.

  2. Label: Mark Account as Active

  3. How to Find Records to Update: Specify conditions…

  4. Object: Account

  5. Conditions: Id Equals {!$Record.AccountId}

  6. Set Field Values for the Account:

    • Customer_Status__c = Active (replace with your actual field)

Click Done.

5) Save, debug, and activate

  1. Save the flow. Give it a name like Opp_ClosedWon_AutoTask_And_AccountUpdate.

  2. Click Debug and test with a sample Opportunity (or use Debug on Canvas).

  3. Click Activate.

6) Test it end-to-end

  1. Open an Opportunity, change StageClosed Won and Save.

  2. Verify:

    • A Task exists under Activity with correct owner/due date.

    • The related Account has Customer_Status__c = Active.

Why this design?

  • Using “Only when updated to meet conditions” prevents duplicate tasks.

  • After-save is required for creating related records (Tasks) and updating other objects (Account).

  • Keeping logic in one flow per object/trigger keeps things maintainable.


Example 2: Screen Flow (quick Case creation)

Goal: Let agents create a Contact (if needed) and a related Case from one guided screen.

Steps (high level)

  1. New Flow → Screen Flow → Create.

  2. Screen: Add inputs

    • Text: Full Name, Email: Email, Phone: Phone

    • Text: Subject, Long Text: Description

    • Picklist (Choice): Priority (Low/Medium/High)

  3. Get Records (Contact): Find existing Contact where Email = {!Email} (Get first record).

  4. Decision: Found?

    • Yes → use that Contact.

    • NoCreate Records (Contact) with Name/Email/Phone.

  5. Create Records (Case):

    • ContactId = Contact from step 3/4

    • Subject, Description, Priority from the screen inputs.

  6. Screen (Confirmation): Show the Case Number.

  7. Save and Activate.

  8. (Optional) Add the flow to an app page: Setup → Lightning App Builder → open page → add Flow component → select your flow → Save and Activate.


Tips & gotchas

  • Naming: Prefix flows (e.g., RTF_Opportunity_ClosedWon_FollowUp).

  • Before-save vs After-save: Use before-save only for fast field updates on the same record; after-save for creating/updating other records.

  • Order of execution: Flows run with other automations—avoid duplicating logic you still have in Workflow Rules/Process Builder.

  • Fault paths: For Create/Update elements, add a Fault connector to a Send Email or Create Log action to capture failures.

  • Deploy safely: Build and test in a sandbox, then deploy via Change Set/DevOps.

  • Access: Ensure users have permission to run the flow or that it runs in System Context when appropriate.

If you want, tell me your object/field names and the exact business rule you need—I’ll tailor the flow steps (including formulas and decisions) precisely to your org.

Post a Comment

0 Comments