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
-
Go to Setup → Process Automation → Flows → New Flow.
-
Choose Record-Triggered Flow → Create.
-
Object:
Opportunity
-
Trigger: “A record is updated”
-
Entry Conditions:
-
StageName
EqualsClosed Won
-
-
When to Run the Flow for Updated Records: Only when a record is updated to meet the condition requirements (prevents repeated runs).
-
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
-
In the Manager tab → New Resource.
-
Resource Type: Formula | Data Type: Date
-
API Name:
FollowUpDueDate
-
Formula:
TODAY() + 3
Click Done.
3) Create the follow-up Task
-
Drag Create Records onto the canvas.
-
Label:
Create Follow-Up Task
-
How Many Records to Create: One
-
How to Set the Fields: Use separate resources, and literal values
-
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
-
Drag Update Records onto the canvas.
-
Label:
Mark Account as Active
-
How to Find Records to Update: Specify conditions…
-
Object:
Account
-
Conditions:
Id
Equals{!$Record.AccountId}
-
Set Field Values for the Account:
-
Customer_Status__c
=Active
(replace with your actual field)
-
Click Done.
5) Save, debug, and activate
-
Save the flow. Give it a name like
Opp_ClosedWon_AutoTask_And_AccountUpdate
. -
Click Debug and test with a sample Opportunity (or use Debug on Canvas).
-
Click Activate.
6) Test it end-to-end
-
Open an Opportunity, change Stage → Closed Won and Save.
-
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)
-
New Flow → Screen Flow → Create.
-
Screen: Add inputs
-
Text:
Full Name
, Email:Email
, Phone:Phone
-
Text:
Subject
, Long Text:Description
-
Picklist (Choice):
Priority
(Low/Medium/High)
-
-
Get Records (Contact): Find existing Contact where
Email = {!Email}
(Get first record). -
Decision: Found?
-
Yes → use that Contact.
-
No → Create Records (Contact) with Name/Email/Phone.
-
-
Create Records (Case):
-
ContactId
= Contact from step 3/4 -
Subject
,Description
,Priority
from the screen inputs.
-
-
Screen (Confirmation): Show the Case Number.
-
Save and Activate.
-
(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.
Comments
Post a Comment
POST Answer of Questions and ASK to Doubt