LearnFrenzy
Sign in Take a free test

Salesforce Flows (Complete) interview · Set 4 of 6

Autolaunched and Scheduled Flows, Subflows and Invocable Apex

  • 6 follow-up questions
  • 4 key points
  • Code examples
Test yourself

Modular, reusable automation

Schedule work, react to events, reuse logic in subflows, and extend Flow with invocable Apex and callouts — keeping each flow small and focused.

  • TriggersSchedules and platform events.
  • ReuseAutolaunched flows and subflows.
  • ExtendInvocable Apex, Flow.Interview and callouts.

Beyond records and screens, flows run on schedules, react to events, call each other and call Apex. These questions check that you can build reusable, modular automation — the mark of a senior admin or developer.

1. How does a schedule-triggered flow work?

It runs at a set time and frequency (once, daily, weekly) and can process a batch of records matching filter conditions — each record runs the flow in bulk-friendly batches. Example: every night, mark open Cases with no activity for 30 days as “Needs Attention”.


2. What is an autolaunched flow used for?

A flow with no trigger and no screens, started by something else: a subflow call, a button, Apex, the REST API, an Agentforce action or a process. It is ideal for reusable logic such as “calculate shipping cost” or “create onboarding tasks”.


3. How do subflows make flows maintainable?

One reusable subflow, many callers

  1. Screen flow: new customerCalls “Create Onboarding Tasks”
  2. Record-triggered: deal wonCalls the same subflow
  3. SubflowInput: AccountId → creates tasks → output: task count

Shared logic lives in one place: fix it once and every caller benefits. Pass data through input and output variables.


4. How do you call Apex from a flow?

Write a method annotated @InvocableMethod that takes and returns lists (so it works in bulk), with @InvocableVariable inputs and outputs that have clear labels and descriptions. It appears as an Action in Flow Builder.

public with sharing class ShippingCostAction {
    public class Input  { @InvocableVariable(required=true label='Weight (kg)') public Decimal weightKg;
                          @InvocableVariable(required=true label='Pincode') public String pincode; }
    public class Output { @InvocableVariable(label='Cost') public Decimal cost; }

    @InvocableMethod(label='Calculate Shipping Cost' description='Returns the shipping cost for a weight and pincode')
    public static List<Output> calculate(List<Input> inputs) {
        List<Output> results = new List<Output>();
        for (Input i : inputs) {
            Output o = new Output();
            o.cost = 40 + (i.weightKg * 12);
            results.add(o);
        }
        return results;
    }
}

5. How do you start a flow from Apex?

Create a Flow.Interview with the flow API name and input variables, call start(), then read outputs with getVariableValue. Useful when Apex needs logic that admins maintain in a flow.

Map<String, Object> inputs = new Map<String, Object>{ 'AccountId' => accountId };
Flow.Interview flow = Flow.Interview.createInterview('Create_Onboarding_Tasks', inputs);
flow.start();
Integer created = (Integer) flow.getVariableValue('TaskCount');

6. What is a platform event-triggered flow?

A flow that runs when a platform event message is published — from Apex, another flow or an external system. It decouples systems: an ERP publishes “Order Shipped”, and a flow updates the order and notifies the customer.


7. How do flows make HTTP callouts?

Use the HTTP Callout action (configured with a Named Credential and a sample response to generate data types) or External Services from an OpenAPI specification. In record-triggered flows, put callouts on an asynchronous path; in screen flows they can run between screens.


8. When should logic move from Flow to Apex?

When the flow becomes very large and hard to follow, needs complex data structures or algorithms, processes very large volumes, needs precise error handling and retries, or runs into limits. Keep the decision points in Flow and move the heavy part into an invocable Apex action.


Remember

Key points

  • Invocable = lists in, lists out

    So flows stay bulk-safe.

  • Subflows for shared logic

    Fix once, used everywhere.

  • Callouts off the save path

    Asynchronous paths in record flows.

  • Flow.Interview from Apex

    Reuse admin-maintained logic.

Interview drill

Follow-up questions

What the interviewer asks after your first answer. Turn on practice mode, answer each one aloud, then reveal.

  1. 1 Can a schedule-triggered flow process millions of records? Intermediate

    It processes records in batches, but very large volumes and complex logic are better in Batch Apex; check limits on scheduled flow interviews per 24 hours.

  2. 2 How do you pass a collection to a subflow? Basic

    Create a collection variable in the subflow marked available for input and map the caller's collection to it.

  3. 3 Can an invocable method make callouts? Intermediate

    Yes, add callout=true to @InvocableMethod; the flow must call it where callouts are allowed (not before uncommitted DML in the same transaction).

  4. 4 What is the difference between an action and a subflow? Basic

    An action runs code or a standard operation (Apex, email, post to Chatter); a subflow runs another flow built in Flow Builder.

  5. 5 How do you publish a platform event from a flow? Intermediate

    Use a Create Records element on the platform event object.

  6. 6 Can you debug a subflow separately? Basic

    Yes — debug it on its own with test input values, or debug the parent and step into the subflow.

Preparing with friends?

Share this page with your study group or placement batch.

Search LearnFrenzy

Esc

Quick links