SalesforceWizard

Salesforce Flow practice exercises (with model answers)

On this page (3 sections)ExercisesKeep goingCommon questions

Flow is now the main automation tool in Salesforce. These exercises build one of each flow type and practise the habits interviewers look for: entry conditions, no DML in loops, and fault paths.

All exercises use the data model from our real estate practice project: Property__c, Buyer__c, Agent__c, Property_Agent__c and Property_Offer__c. Build Task 1 of that project first (about an hour), in a free Developer Edition org. Each exercise has a level, a check so you know it works, and a model answer to open after you have tried.

Exercises

1. Before-save field update

Beginner

When an offer is created without a status, set Status to Submitted and Offer Date to now.

Check it works
  • A new offer saved without a status shows Submitted and today's date and time.
Show a model answer

Record-triggered flow on Property_Offer__c, A record is created, optimised for Fast Field Updates. Use an Assignment element to set $Record.Status__c and $Record.Offer_Date__c = $Flow.CurrentDateTime. Before-save flows need no Update Records element and are much faster than after-save.

2. After-save: create a related task

Beginner

When an offer is created, create a task for the property's lead agent to call the buyer within two days.

Check it works
  • The task appears on the offer with the right owner and due date.
Show a model answer

After-save flow. Get Records on Property_Agent__c where Property = $Record.Property__c and Lead Agent = true, then find the agent's user. Create Records for a Task with WhatId = $Record.Id and ActivityDate = $Flow.CurrentDate + 2. Add a Decision for the case where no lead agent is found.

3. Run only when a value changes

Intermediate

When an offer's status becomes Accepted, set the property's status to Under Offer.

Check it works
  • Accepting an offer updates the property.
  • Editing the accepted offer's notes later does not run the flow again.
Show a model answer

Entry condition Status equals Accepted, with "Only when a record is updated to meet the condition requirements". Then Update Records on $Record.Property__r (use "Update records related to the triggering record"). Without that setting, the flow runs on every edit while the status stays Accepted.

4. Loop without DML inside

Intermediate

When an offer is accepted, set every other open offer on the same property to Rejected.

Check it works
  • Accept one of three offers: the other two become Rejected with a single Update Records element in the flow.
Show a model answer

Get Records: offers where Property = $Record.Property__c, Id not equal to $Record.Id, and Status not equal to Rejected. Loop through them, in the loop Assign Status = Rejected and add the record to a collection variable. After the loop, one Update Records on the collection. Even simpler: an Update Records element with these filter conditions does it with no loop at all.

5. Scheduled path reminder

Intermediate

If an offer is still Submitted three days after it was created, email the lead agent.

Check it works
  • Use Setup, Time-Based Workflow (or Scheduled Jobs) to see the pending path.
  • Changing the status before three days cancels the reminder.
Show a model answer

Add a scheduled path to the record-triggered flow: 3 days after Created Date. Set the entry condition to Status equals Submitted with "Only when updated to meet the condition" so the path is cancelled when the status changes. Scheduled paths run in the background as the Automated Process user.

6. Screen flow with a lookup

Intermediate

Build a screen flow for agents: choose a buyer and a property, enter an amount, and create an offer. Add it as a quick action on the property page and pass in the property ID.

Check it works
  • Launched from a property, the property is already filled in and the offer is created.
Show a model answer

Create a text variable named recordId, available for input; the quick action fills it automatically. Use the Lookup component for the buyer. Add a fault path to Create Records that shows {!$Flow.FaultMessage} on a screen, so validation rule messages are shown to the user.

7. Subflow and fault handling

Advanced

Move the commission calculation into an autolaunched subflow with inputs and outputs, and call it from two different flows. Add a fault path in each caller that emails the admin.

Check it works
  • Both flows use the same subflow.
  • Force an error (for example by deactivating a validation rule bypass): the admin receives an email with the fault message.
Show a model answer

Mark subflow variables "Available for input" or "Available for output". Fault paths only catch errors from elements that have them, so add one to each data and action element that can fail. In production, many teams log faults to a custom object instead of sending emails.

Keep going

Common questions

01

Before-save or after-save?

Use before-save (Fast Field Updates) when you only change fields on the record being saved. Use after-save when you need the record ID, need to change other records, send emails or call subflows and actions.

02

How many flows should an object have?

There is no fixed rule. Many teams keep one before-save and a small number of after-save flows per object, use entry conditions so each only runs when needed, and set the trigger order so the sequence is predictable.

Chat on WhatsApp