Skip to content
Skip to content
SalesforceFox

SalesforceFox

Easy way Learning & Exploring Salesforce !

  • Home
  • All Blogs
  • How To
  • Tips & Tricks
  • Salesforce Quiz
  • Resources
  • About
Display Apex-Defined Collection Data Directly into Screen Flow DataTable

Display Apex-Defined Collection Data directly into Screen Flow Data Table

Piyush LakhaniOctober 10, 2025October 10, 2025

With every release, Salesforce is making its hot favourite tool, Flow, more and more powerful. Here we will understand one very useful update from winter’ 26 release. We will see how we can display Apex-defined collection data into Screen Flow Data Table.

Table of Contents
[Open][Close]
  • The Problem (Before Winter ’26)
  • The New Feature (Winter ’26)
  • Business Use Case
  • Step-by-Step implementation
    • 1. Using Get Records vs Apex @InvocableMethod
    • 2. Create Apex class with @InvocableMethod
    • 3. Build Screen Flow
      • i. Adding First Screen for User to enter Opportunity Amount
      • ii. Calling Apex Action to get filtered Opportunities
      • iii. Adding Data Table with apex action data on screen
      • iv. How entire Screen Flow looks like
    • 4. Filter Opportunity Screen Flow In Action

The Problem (Before Winter ’26)

You must have used Data table to display data in Tabular format into Screen flow wherein you first need to create collection in flow and then add it as source of data table.

However, it is not always possible to create data collection in flow itself if data we need to display is coming from various objects or if data is large or complex.

We often use Apex actions to fetch complex data — like API responses, formatted lists, or joined data models — wrapped in an Apex-defined class

However,

  • We could not directly display this data in a Data Table component in the screen flow.
  • We had to transform the Apex-defined collection into a standard SObject or string collection.
  • This meant extra loops, variables, and complexity inside the Flow.

The New Feature (Winter ’26)

Now in Screen Flow, We can natively display Apex-defined Collections directly into Data Table component.

This makes our life easy when it comes to displaying complex data in screen flows. Therefore now, We can build/retrieve Data in Apex class and use its output as source collection directly into data table element inside Screen flow.

Let’s understand this with business case scenario

Business Use Case

An Account Executive at SalesforceFox wants a quick way to filter all Opportunities by a minimum Amount — directly from the Salesforce Home page.

He wants to enter a value (say, $50,000) and instantly view all Opportunities with an Amount greater than or equal to that number, without navigating to multiple list views or reports.

To make this interactive and user-friendly, We’ll use a Screen Flow embedded on the Home page.

Step-by-Step implementation

1. Using Get Records vs Apex @InvocableMethod

Well, we can use Get Records element in screen flow to filter Opportunities by Amount. However, using Apex-define Collections gives us more flexibility and it is reusable for other actions as well.

Before Winter ’26, It was not possible to directly use that Apex-defined collections as source of Data Table to display on screen. But now, we can do all complex data processing in Apex class itself and then using @InvocableMethod we can that data collections inside Screen Flow Data Table.

2. Create Apex class with @InvocableMethod

Here, We will create Apex class with @InvocableMethod. This is special decorator to be used in apex method so that we can use this from screen flow actions.

public with sharing class OpportunityWrapper {
        @AuraEnabled
        public Id opportunityId { get; set; }
        
        @AuraEnabled
        public String opportunityName { get; set; }
        
        @AuraEnabled
        public String accountName { get; set; }
        
        @AuraEnabled
        public String stageName { get; set; }
        
        @AuraEnabled
        public Decimal amount { get; set; }
        
        @AuraEnabled
        public Date closeDate { get; set; }
        
        @AuraEnabled
        public Decimal probability { get; set; }
        
        @AuraEnabled
        public String type { get; set; }
        
        @AuraEnabled
        public String leadSource { get; set; }
        
        @AuraEnabled
        public String ownerName { get; set; }
        
        @AuraEnabled
        public Date createdDate { get; set; }
        
        @AuraEnabled
        public String forecastCategory { get; set; }
        
        @AuraEnabled
        public Boolean isClosed { get; set; }
        
        @AuraEnabled
        public Boolean isWon { get; set; }
}
public with sharing class OpporuntityInvocableController {

    public class FlowInputs {

        @InvocableVariable(
        	label='Minimum Amount' 
        	description='Filter opportunities by minimum amount')
        public Decimal minAmount;  
    }
  
    public class FlowOutputs {

        @InvocableVariable(label='Opportunity Details')
        public List<OpportunityWrapper> opportunityDetails;
    }

    @InvocableMethod(
    	label='Get Opportunity Details' 
    	description='Retrieves opportunity details for display in Screen Flow dataTable'
    	category='Opportunity')
    public static List<FlowOutputs> getOpportunityDetails(List<FlowInputs> inputs) {
        FlowInputs input = inputs[0];

        Decimal minAmount = input.minAmount;
        
        // Build dynamic query
        String query = 'SELECT Id, Name, Account.Name, StageName, Amount, CloseDate, ' +
                      'Probability, Type, LeadSource, Owner.Name, CreatedDate, ' +
                      'ForecastCategory, IsClosed, IsWon ' +
                      'FROM Opportunity WHERE Id != null';
        
        if (input.minAmount != null) {
            query += ' AND Amount >= :minAmount';
        }
         
        // Execute query
        List<Opportunity> opportunities = Database.query(query);
        
        // Transform to wrapper objects
        List<OpportunityWrapper> oppWrappers = new List<OpportunityWrapper>();
        
        for (Opportunity opp : opportunities) {
            OpportunityWrapper wrapper = new OpportunityWrapper();
            wrapper.opportunityId = opp.Id;
            wrapper.opportunityName = opp.Name;
            wrapper.accountName = opp.Account?.Name;
            wrapper.stageName = opp.StageName;
            wrapper.amount = opp.Amount;
            wrapper.closeDate = opp.CloseDate;
            wrapper.probability = opp.Probability;
            wrapper.type = opp.Type;
            wrapper.leadSource = opp.LeadSource;
            wrapper.ownerName = opp.Owner?.Name;
            wrapper.createdDate = opp.CreatedDate.date();
            wrapper.forecastCategory = opp.ForecastCategory;
            wrapper.isClosed = opp.IsClosed;
            wrapper.isWon = opp.IsWon;
            
            oppWrappers.add(wrapper);
        }        
        // Prepare output
        FlowOutputs output = new FlowOutputs();
        output.opportunityDetails = oppWrappers;
        
        return new List<FlowOutputs>{ output };
    }
}
  • Here, we have created one method getOpportunityDetails() with decorator @InvocableMethod so that we can call this from screen flow actions.
  • We want to pass input from flow (minimum amount in our case) and want Opportunity details as output so we have created two wrapper class called FlowInputs & FlowOutputs to structure and pass data to and from a Flow

3. Build Screen Flow

i. Adding First Screen for User to enter Opportunity Amount

First of all, we will add screen element and inside the screen add Text element to so that user can enter opportunity’s minimum amount to filter it

ii. Calling Apex Action to get filtered Opportunities

Now, as shown below add Action element and call our apex class we created above which will provide us filtered opportunities

Adding Apex Action to Screen Flow

For this Apex class we have defined Input and Output parameters, As shown below, as an input, we will pass minimum amount that user has entered in first screen input and then apex class will return us filtered opportunities which is available as output source of this apex actions

Setting Input Variable to Apex actions

iii. Adding Data Table with apex action data on screen

Now, Let’s add Screen element and add Data Table into it

Once we have apex action defined. now, it’s time to feed its output sources as source to our Data Table element.

As a shown below, we have added Opportunity Details output source from Apex action as a source collection to data table.

Setting Output source from Apex action as source collection to Data Table in Screen element

Once source collection is selected for Data Table, make sure to configure rows and columns for the same as shown below

Configure Rows in Data Table in Screen Flow
Configure Columns in Data Table in Screen Flow

iv. How entire Screen Flow looks like

Apex-Defined Collection in Data Table Screen Flow by SalesforceFoxcom

4. Filter Opportunity Screen Flow In Action

Apex-Defined Collection in Screen Flow DataTable

Share this Now :

Related Posts:

  • Mastering SOLID principles in Apex
    Mastering SOLID Principles in Apex: Write Cleaner,…
  • How To Use Flow Approval Process instead of Classic Approval Process
    How to use Flow Approval Process In Salesforce ?
  • How to Clone a User in Salesforce : Deploy screen flow solution to your sandbox with few clicks by SalesforceFox.com
    How to Clone a User in Salesforce : Deploy screen…
  • Add Custom Toast Messages In Screen Flows In Salesforce
    Make Salesforce Screen flows more Interactive with…
Admin, Apex, Flow

Post navigation

Previous: How to Secure Your Salesforce Org: First Steps Against Cyber Attacks and Social Engineering
Next: User Access Policy in Salesforce : The Smartest way to Automate User Management Jobs

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Get Weekly Salesforce Quiz

Categories

  • Admin (8)
  • Apex (6)
  • Automation (7)
  • Best Practices (6)
  • Flow (5)
  • LWC (4)
  • Security (1)
  • SOQL (1)
  • Trigger (1)
  • Uncategorized (1)

Recent Posts

  • User Access Policy in Salesforce : The Smartest way to Automate User Management Jobs
  • Display Apex-Defined Collection Data directly into Screen Flow Data Table
  • How to Secure Your Salesforce Org: First Steps Against Cyber Attacks and Social Engineering
  • Make Salesforce Screen flows more Interactive with Toast Messages
  • How to Zip & Unzip files Natively in Salesforce: Use This Ready-to-Use ZIP Utility

Tags

Admin Apex Aura Component Automation Best Practices Development Email Alerts Flow Flow Approval Process How To Lightning Experience LWC Reports Scheduled Jobs Security SOQL Tips Trigger User Management

Archives

  • November 2025 (1)
  • October 2025 (1)
  • August 2025 (1)
  • July 2025 (1)
  • June 2025 (2)
  • May 2025 (1)
  • April 2025 (2)
  • March 2025 (2)
  • January 2025 (2)
  • December 2024 (1)
  • October 2024 (1)
  • September 2024 (1)
  • August 2024 (1)
  • June 2024 (1)
  • April 2024 (1)
  • March 2024 (1)
  • October 2023 (1)
  • Linkedin
  • Youtube
  • Privacy Policy
  • Terms of Use
  • Contact
Theme: BlockWP by Candid Themes.
© 2023-2026 | SalesforceFox.com