Salesforce Developer Interview Question

How do you decide between Flow and Apex for a piece of automation?

What the interviewer is probing, how to structure your answer, and a spoken example you can adapt.

Quick answer

Start from who will maintain it and how complex it is. Flow suits straightforward record automation, guided screens and logic admins should be able to change, and before save flows are very efficient for same record updates. Apex suits complex logic, heavy data volumes, careful error handling, callouts with retries, reusable services and anything needing proper unit tests. Avoid mixing both on one object without a clear rule about which owns what.

Why interviewers ask this

Salesforce pushes Flow hard, and the interviewer wants a pragmatic view rather than a developer's reflex to code everything or an admin's reflex to build everything in Flow. They listen for criteria such as complexity, volume, testability, error handling and who maintains it. Mentioning the risk of overlapping flows and triggers on the same object, and the need for a team convention, shows you have untangled a messy org.

How to structure your answer

  • Name the criteria: complexity, volume, maintainers and testing.
  • Describe where Flow is the right tool.
  • Describe where Apex is the right tool.
  • Explain how you avoid conflicts when both exist.

Example answer

Spoken example, first person

I start with who will own it and how complicated it really is. If the logic is a few conditions and field updates, and the business wants admins to adjust it without a release, Flow is the right tool, and for updates to the same record a before save flow is about as efficient as it gets. Screen flows are also great for guided processes that would otherwise need a custom component. I move to Apex when the logic gets complex enough that the flow becomes a sprawling diagram nobody can read, when it processes large volumes and I need tight control over queries and limits, when error handling matters, such as partial failures or retries on a callout, or when other code needs to call it as a service. Apex also gives me real unit tests with assertions. What I care about most is not mixing them carelessly. On one org the same field was set by both a flow and a trigger, and the result depended on the order of execution. We agreed a rule per object, flow led or code led, and documented the exceptions.

Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.

See how it works

Follow-up questions to expect

  • How would you test a complex record triggered flow?
  • What would make you rewrite an existing flow in Apex?
  • How do you handle errors in a flow that updates many records?

Related salesforce developer questions

Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.

Predict my questions

Rehearse the hard questions before they are asked

Practise with a live copilot, then walk in ready. A $29 Session Pass gets you through the interview with no subscription and no lock-in.

Get GhostPilot