Flexi Kanban
  • Introduction
    • πŸ“ƒAbout Flexi Kanban
    • βš–οΈFlexi Kanban in Comparison with Other
    • πŸ“˜What are Kanbans?
    • πŸ“•User's Guide to the Kanban Boards
  • Standard Dashboard
    • πŸš€Getting started
      • How to Build a Simple Kanban Using Creation Wizard Abilities
      • Demo Example: Task Dashboard
      • Demo Example: Events Dashboard
      • Demo Example: Opportunities Dashboard
      • Demo Example: Gantt Dashboard
      • Demo Example: Cases Dashboard
    • πŸ“Basics
      • How to Create Standard Dashboard
      • How to Create Child Dashboard
      • How to Incorporate Child Dashboard into Lightning Page
      • How to Open Dashboard in builder (Edit)
      • How to Share Dashboard
      • How to Clone Dashboard
    • πŸ—οΈConfigure Dashboard
      • Working with Dashboard Layout
      • How to Configure Dashboard Basic Properties
      • How to Configure Dashboard Filters
      • How to Add Dashboard Statistics
      • How to Configure Variables
      • How to Configure Events
      • How to add Dashboard Buttons and Menus
    • πŸ™οΈConfigure Column
      • How to Π‘onfigure Column Properties
      • How to Set Column Groups
      • How to Set and Use Column Custom Attributes
      • How to configure Column Data Source
      • How to work with Related Objects
      • How to configure Column Header
      • How to configure Column Body
      • How to configure Column Footer
      • How to configure Column Container and Filters
    • 🎫Configure Card
      • How to configure Card Properties
      • How to configure Card Data Source and Conditions
      • How to configure Card Compact Layout
      • How to configure Card Layout
      • How to configure and use Card Custom Attributes
      • Configuring Card Movement and Column Junctions
      • Configuring Card Actions
    • πŸ“šGroups of Cards
      • How to configure Card Grouping
    • πŸ”§Tools
      • Using Merge Field Picker
      • Using Formula Editor
      • Configuring CSS styles
      • Configuring Rows, Cells, Menus and Buttons
      • Configuring Handlers
    • πŸ‘“Using Dashboard
      • How to use Kanban API actions
      • How to Incorporate Dashboard into Lightning Page
      • How to build the link to the Dashboard
      • How to Work with Variables
      • How to debug Dashboard
      • How to Work with Filters and Orders
    • ✨Howtos and Best Practices
      • How to configure communication between Dashboards
      • How to configure communication between Dashboard and Form
      • How to display different layouts for the same kanban card
      • How to design kanban for your needs
        • How to colorize cards
        • How to add a quick-filter column
      • What inactive column can be used for
      • Tips and Tricks
  • Composite Dashboard
    • πŸ—„οΈIntroduction
      • πŸ”§How to Create a Composite Dashboard
    • πŸͺ›Working with Composite Dashboard Layout
      • Configuring Parent Dashboard
      • Configuring Child Dashboard
    • πŸ–‡οΈConnections Between Dashboards
    • πŸ”¬Examples
      • !! Calendar Dashboard
    • πŸ₯‡Howtos and Best Practices
      • How to Pass Variables Between Parent and Child Dashboards
  • Components
    • πŸ“‹Forms
      • πŸ“‘Basics
        • Form Building Overview
        • Working with Form Settings
        • Working with Source Object fields
        • How to Preview the Form
        • How to configure the Form Sharing Rules
        • Understanding the Form Dependencies
        • Working with Conditional Styles
        • Working with Conditions
        • Search Over the Form
      • πŸͺ›Tools
        • Variables
        • Additional Fields
        • Context Object
        • Form Action
        • Event
      • Components
        • Add and Remove Form Components
        • Components Basic Properties
        • Components Validation Rules
        • Styling Form and Form Components
        • String Field
        • Text Area Field
        • Rich Text Field
        • Lookup Field
        • Date Field
        • Datetime Field
        • Time Field
        • Number Field
        • Currency Field
        • Multi-Select Field
        • Picklist Field
        • Option: Section
        • Option: Static Text
        • Option: Image
        • Option: Blank Space
        • Option: File
        • Option: Custom Button
        • Option: Custom URL
        • Option: Nested Form
        • Option: Lightning Component
        • List. Related Lists.
      • Using Form
        • How to incorporate Form into the Lightning Page
        • How to incorporate Form into Screen Flow
        • How to build the link to the Form
        • (unpublished, empty)How to incorporate Form into the Lightning Component
        • How to run Form Action from Lightning Component
      • Tricks, Hints and Best Practices
        • How to configure communication between Forms
        • How to pre-populate form fields
        • Deployment of Forms
        • What Are Parameters?
    • 🀾Actions/Action Groups
      • Basics
        • Working with Actions
        • Working with Action Groups
        • Working with Functions
        • Working with Context objects
        • Working with Conditions
      • Types
        • Validation Rule Action
        • Define Variable Action
        • Create Record Action
        • Update Records Action
        • Delete Records Action
        • Send Email Action
        • Callout Action
        • Execute Apex Action
        • KanBan API Action
      • Using Actions
        • !!unpublished empty!! How to execute Action/Group from the SF Process/Flow Builder
        • How to execute Action/Group through the REST api
        • !!unpublished empty!! How to execute Action/Group from the Einstain Bot
        • !!unpublished empty !! How to execute Action/Group from APEX
      • Best Practices
        • !! How to use Execute in background option
        • !! Deployment Actions/Action Groups
  • πŸ“–References
    • βš™οΈApplication Settings
    • ♾️Functions
      • SObject
      • Text
      • Logical
      • Numeric
      • Date and Time
      • JSON
      • System
      • Charts
    • πŸ—ƒοΈQuery Conditions
    • Apex Data Provider
    • πŸ“How to add a Kanban to Navigation Items Panel
    • πŸ‘₯Manage Licenses
    • πŸͺͺAssign Permission Sets
    • πŸ“¦Deployment
      • Deploying Using Standard Credentials
      • Deploying Using Connected App Authentication
      • How to configure the Salesforce Connected Application for Flexi Kanban deployment
  • Grant Login Access to Support
  • Subscription Plans
  • Support Agreement
  • Access License Agreement
  • Privacy Policy
Powered by GitBook
On this page
  1. References

Apex Data Provider

The Apex Data Provider is designed to enhance the functionality of lookup and list form elements by enabling the integration of data obtained through custom Apex classes.

This feature is particularly beneficial when data needs to be curated or processed using specific logic tailored to your unique requirements. Additionally, it offers the flexibility to fetch data from external sources such as web services or file contents, making it an indispensable tool for dynamic data integration in your applications.

Your Apex Data Provider class must implement the following interface:

FLX_KB.KanBanInterfaces.FormBuilderApiInterface

This code demonstrates how to dynamically load and manipulate data for a Salesforce UI component, like a list or a lookup field, using Apex.

public class with sharing implementing the interface FLX_KB.KanBanInterfaces.FormBuilderApiInterface
{
    // Define List data
    public Object loadListData(Map<String, Object> parameters)
    {       
        Integer pageNumber = Integer.valueOf(parameters.get('pageNumber'));
        Integer pageSize = 10;
        Integer offset = (pageNumber - 1) * pageSize;
        Integer sizeTotal = [select count() from Opportunity];
        List<Map<String, Object>> opportunitiesList = 
            getOpportunitiesList(pageSize, offset);
        
        // Return list properties and records
        return new Map<String, Object>{
            'pageNumber' => pageNumber,
            'pageSize' => pageSize,
            'hasNext' => sizeTotal > pageSize * pageNumber,
            'total' => offset + opportunitiesList.size(),
            'records' => opportunitiesList,
            // Define List Columns
            'columns' => new List<Map<String, Object>>{
                // Column definitions
                {'name' => 'name', 'label' => 'Opportunity Name', 'sortable' => 'false'},
                {'name' => 'contractName', 'label' => 'Contract Name', 'sortable' => 'false'},
                {'name' => 'contractOwner', 'label' => 'Contract Owner', 'sortable' => 'false'},
                {'name' => 'campaignName', 'label' => 'Campaign Name', 'sortable' => 'false'},
                {'name' => 'campaignActualCost', 'label' => 'Campaign Actual Cost', 'sortable' => 'false'}
            },
            // Define actions
            'actions' => {'view' => {}} 
        };
    }

    // Collect records for the List
    private List<Map<String, Object>> getOpportunitiesList(
        Integer pageSize, Integer offset)
    {
        List<Map<String,Object>> result = new List<Map<String,Object>>();
        // Query for opportunities
        for (Opportunity opp : [
            select Id, Name, Contract.Name, Contract.Owner.Name, 
            Campaign.Name, Campaign.ActualCost 
            from Opportunity 
            order by id 
            limit :pageSize offset :offset
        ])
        {
            // Adding each opportunity to the result
            result.add({
                'id' => opp.Id, 
                'name' => opp.Name, 
                'contractName' => opp.Contract.Name, 
                'contractOwner' => opp.Contract.Owner.Name, 
                'campaignName' => opp.Campaign.Name, 
                'campaignActualCost' => 
                    String.valueOf(opp.Campaign.ActualCost == null ? 0 : opp.Campaign.ActualCost)
            });
        }
        return result;
    } 
    
    // Define Lookup data
    public Object loadLookupData(Map<String, Object> parameters)
    {
        system.debug('parameters ' + parameters);
        List<Map<String, Object>> result = new List<Map<String, Object>>();
        String defaultValue = (String)parameters.get('value'); 
        String searchString = (String)parameters.get('filter'); 
        
        // Build query based on default value
        String request;
        if (String.isBlank(defaultValue)) 
        {
            request = 'SELECT id, name, ActualCost from Campaign';
        } else {
            request = 'SELECT id, name, ActualCost from Campaign where id = \'' 
                      + defaultValue + '\'';
        }
        Map<Id, Campaign> campaignItems = new Map<Id, Campaign>(
            (List<Campaign>)Database.query(request));
        
        // Process and add campaign items to result
        for (Campaign campaignItem : campaignItems.values())
        {
            String campaignNameAndAmount = campaignItem.Name + ' - $' + 
                (campaignItem.ActualCost == null ? '0' : 
                String.valueOf(campaignItem.ActualCost));
            if (String.isBlank(searchString))
                result.add({'Id' => campaignItem.Id, 'Name' => campaignNameAndAmount});
            else if (campaignNameAndAmount.containsIgnoreCase(searchString))
                result.add({'Id' => campaignItem.Id, 'Name' => campaignNameAndAmount});
        }
        system.debug(result);
        return result;
    }
    
    // Load related list data (currently not implemented)
    public Object loadRelatedListData(Map<String, Object> parameters)
    {
        return null;
    }
}

Last updated 8 months ago

πŸ“–