You are here:
Create a Simple After-Save Record-Triggered Flow
Learn how to build an after-save record-triggered flow that automatically creates a record. This example creates a follow-up task whenever a user creates a lead record, ensuring your team never misses an important next step.
Required Editions
| View supported editions. |
| User Permissions Needed | |
|---|---|
| To open, edit, create, activate or deactivate a flow using all flow types, elements, and features available in Flow Builder, including Einstein and Agentforce for Flow: | Manage Flow |
A new lead requires follow up because it's just the beginning of the customer relationship. After you create a lead, there's usually follow-up work to do, such as reaching out to the lead, scheduling an intro call, or sending a thank-you note after a call.
Instead of manually creating these tasks every time, run a flow that creates them automatically. Whenever a user creates a lead, your flow creates a task assigned to the lead owner with a reminder to follow up with the lead.
This example uses after-save flow because you're creating a record (the task), which requires the lead to be saved first so it has a record ID. You need the lead record ID to link the task to the lead owner.
Create a Record-Triggered Flow
-
Open the Flows list view.
- From Setup, in the Quick Find box, enter Flows, and then select Flows.
- From the Automation app, select the Flows tab.
- From the Flows tab in any Lightning app, click the actions menu and select Open Flow.
-
Create a record-triggered flow.
- From the Automation Lightning app, click New. Select the Triggered Automations tile, and then select the Record-Triggered Flow tile.
- From Setup, click New Flow, select the Triggered Automations tile, and then select the Record-Triggered Flow tile.
The Configure Start panel opens.
Specify When Your Flow Runs
You want the flow to run when a lead is created. To follow up with the lead, you need either an email or a phone number.
- On the Configure Start panel, for Object, select Lead.
-
For Trigger the Flow When, select A record is
created.
To keep the flow from running when the new lead doesn't have any contact information, add conditions to the Start element.
-
In the Set Entry Conditions section, for Condition Requirements, select
Any Condition Is Met (OR).
The Any Condition is Met (OR) option means just one of the conditions must be met. The flow runs if the lead has an email address, a phone number, or both.
- For Field, select Email.
-
For Operator, select Is Null.
Null means that there’s no value.
- For Value, select False.
-
Click + Add Condition.
Now, add the condition for the phone number.
- For Field, select Phone.
- For Operator, select Is Null.
- For Value, select False.
-
For Optimize the Flow for, select the Actions and Related
Records tile.
The Action and Related Record option is the option that makes it an after-save flow.
The start element looks like this.
Create a Task with a Create Records Element
The Create Records element is how you create records in a flow. You specify what type of record to create and fill in its field values.
-
Create a task with a Create Records element.
-
Click
, and select Create Records.
The Create Records panel opens. -
For Label, enter Create Follow-Up Task.
The API name auto-fills based on your label.
- For Description, enter Creates a task for the lead owner to follow up with the lead.
-
For How to set record field values, select Manually.
This step gives you full control over which fields to populate and what values to set.
-
For Object, select Task.
This step tells Salesforce you're creating a task record.
- In the Set Field Values for the Task section, for Field, search for and select Assigned To ID.
-
For Value, search for and select Triggering Lead and then
search for and select Owner ID. If there are multiple Owner
ID options, select the Owner ID that's a plain text value, not a record lookup. It
doesn't have an arrow next to it.
This assigns the task to whoever owns the lead. The task shows up on their task list automatically.
- Click + Add Field.
- For Field, select Name ID.
-
For Value, search for and select Triggering Lead and then
search for and select Lead ID.
This step links the task to the lead so when someone views the lead, they see the task in the lead's Activity Timeline.
- Click + Add Field.
- For Field, select Subject.
-
For Value, enter Follow up with new lead.
The subject of the task is what's shown on the user's task list.
- Click + Add Field.
- For Field, select Priority.
-
For Value, select High.
The Priority field is a required field to create a task. If you don't set a value for Priority, the flow fails when it runs. Following up with a new customer is important, so mark it as a high priority.
- Click + Add Field.
- For Field, select Status.
-
For Value, select Not Started.
The Status field is another required field to create a task. Set it as not started because it's new.
- Click + Add Field.
- For Field, select Due Date Only.
-
Click
-
For the Due Date value, create a formula resource that sets the due date to 3 days
from today.
- In the Value field, select New Resource.
- For Resource Type, select Formula.
- For API Name, enter ThreeDaysFromNow.
- For Description, enter Calculates the date 3 days from today for the task due date.
-
For Data Type, select Date.
We select Date because we want the formula to return a date that's three days from when the flow runs to populate our due date.
-
For Formula, enter TODAY()+3.
This formula takes the day that the flow runs and adds 3 days to it.
- Click Check Syntax to make sure that the formula is valid.
-
Click Done.
- Back in the Create Records panel, verify that the Due Date Only value is your new ThreeDaysFromNow formula.
The Create Records element looks like this.
Save the Flow
- Click Save.
-
For Flow Label, enter Create Follow-Up Task When Lead
Created.
The Flow API name auto-fills.
- For Description, enter Automatically creates a follow-up task for the lead owner when a lead is created.
- Click Save.
Test and Activate Your Flow
Use the debugger to verify that a task gets created automatically.
-
Create a test lead.
- Go to your lead record list view.
- Create a lead with sample data.
-
Run the flow debugger.
- Go back to your flow.
- Click Debug.
- Search for and select your test lead.
- Click Run.
-
Review the debug log.
- If the debug run finishes without errors, go to the next step.
- If the debug run had errors, fix the errors listed in the debug log.
-
Update your test lead and run the debugger multiple times to check these scenarios:
- The lead doesn't have a phone number or an email.
- The test lead has just a phone number.
- The test lead has just an email.
- The test lead has a phone number and an email.
-
If everything works as expected, click Activate.
The flow is now active and runs automatically whenever a user creates a lead.
- Create another test lead to test the trigger. After the lead is created, verify that there's a new task in the lead's Activity Timeline.
What's Next
You've built an after-save record-triggered flow that automatically creates a record. Now, whenever anyone creates a lead, your flow creates a follow-up task automatically—no manual work required.
You learned important new skills:
- Creating an after-save record-triggered flow.
- Using the Create Records element to create a record.
- Setting field values on the new record, including references to the triggering record.
- Creating a simple formula to calculate a date.
- Linking related records together (the task to the lead).
Now, you can give your flow more functionality by adding other elements. Look at these examples of record-triggered flows for more ideas.

