All pages
Powered by GitBook
1 of 5

Loading...

Loading...

Loading...

Loading...

Loading...

DataSource Setup

The DataSource Setup feature allows you to connect and manage various data sources. This functionality enables seamless integration of internal and external data, allowing real-time data retrieval. Additionally, users can monitor the connection status of the DataSource and make adjustments as needed to maintain optimal performance.


🔸 Steps to Configure DataSource

1. In the top-right corner of the List Builder, click the DataSource Setup button to access the DataSource settings screen.

List Builder Screen

2. Add a DataSource configuration in either the Basic or Advanced tab:

  • : For using internal data.

  • : For integrating external data or complex logic.

3. Once the setup is complete, click the Lists Setup button in the top-right corner to return to the List Builder.

Basic DataSource

The Basic DataSource enables the integration of data from related objects within Salesforce to be displayed in a single List. By using a Basic DataSource, users can merge data across related objects, ensuring a comprehensive view of information. The real-time data integration ensures that any updates to the connected objects are automatically reflected, providing users with the most up-to-date data. This feature supports more holistic data views, enabling more informed decision-making.

For example, if the object configured in the List Configurator is Product2, and you want to display the price from the related PricebookEntry object, the Basic DataSource can be used to query matching PricebookEntry records and display the product and price together in the List.

Multiple DataSources can be configured and used simultaneously.


🔸 Steps to Configure Basic DataSource

1. Click the ➕ button to add a new DataSource.

DataSource Setup

2. Search for and select the target object for the DataSource.

Search Object

3. Configure the DataSource by enabling activation, adding a description, setting conditions for querying the target object, and mapping fields to integrate the DataSource data into the List.

DataSource Setup
No.
Name
Description
Required

1

Active

Activates the DataSource. If not activated, the DataSource will not function during List configuration.

2

Description

Provides a description of the DataSource for clarity.

3

Basic
Advanced
DataSource Setup Screen

Add and Configure Actions

To integrate information retrieved from a DataSource into a List, field mapping actions are performed. This process ensures accurate data merging by setting a common field as a Key between the DataSource and List records. Through this mapping, data from various sources can be effectively consolidated and managed.

What is Key?

A common value used to merge data from the DataSource into the List.

Action Mapping Notes

  • DataSource Field

    Displays the fields from the object specified in the DataSource. These fields provide the source data to be integrated into the List.

  • List Field

    Displays the fields from the object specified in the List Configurator. These fields serve as the destination for mapping the DataSource data.

  • Virtual Field


🔸 Steps to Add and Configure Actions

1. In the Actions section, click the edit icon in the Key row.

2. Select the DataSource field and the List field with common values, then click the Save button.

3. Verify that the configured Key is applied correctly, then click the Add Action button.

4. Select the DataSource field from which data will be retrieved and choose the List field or virtual field where the data will be saved, then click the Save button.


🔸 Example

You want to display the price from the PricebookEntry object alongside a product list configured with Product2 in the List.

  1. Search for and select PricebookEntry in the DataSource.

  2. (Optional) In the Condition field, enter IsActive = true (similar to an SOQL WHERE clause).

  3. To merge data for the matching PricebookEntry record:

    1. Click the edit button in the

Displays virtual columns created in the List. These fields allow for displaying additional data derived from the DataSource without modifying the original object structure.
Key
row.
  • In the popup, configure the following, then save:

    • DataSource Field: Product2Id

    • List Field: Id

  • To display the UnitPrice from PricebookEntry in the List:

    1. Create a virtual column (e.g., SBLS_Virtual1) in the Datatable Setup.

    2. Click the Add Action button.

    3. In the popup, configure the following, then save:

      • DataSource Field: UnitPrice

      • Virtual Column: SBLS_Virtual1

  • Key Setting
    Key Setting Modal
    Edit Key Modal
    Add Action Modal
    Datatable Setup
    Basic DataSource Setup

    Conditions

    Specifies conditions for querying the target object.

    Use the Query Wizard to write conditions easily.

    ⚠️ When using fields from the List’s configured object, use IN instead of =. $Current refers to the List’s configured object.

    🆗 Product2Id IN {$Current.Id} ❌ Product2Id = {$Current.Id}

    4

    Action

    Performs field mapping to integrate the information retrieved by the DataSource into the List.

    ✔️

    Advanced DataSource

    The Advanced DataSource allows you to retrieve and display data from external servers alongside Salesforce data. By leveraging custom Apex Classes or Flows to fetch data, this feature offers greater flexibility and diverse data access compared to internal DataSources. It enables the integration of Salesforce data with external systems, providing a unified view in the List while supporting complex business logic and data transformations.

    For instance, if you want to display real-time inventory data from an external server, you can write a REST API call in an Apex Class and specify it as the Advanced DataSource, enabling the data to be displayed in the List.

    Multiple DataSources can be configured and used simultaneously.

    What is Key?

    A Key is a common field used to merge data from the DataSource into the List. It ensures proper integration by linking data from the external DataSource with the List records.

    Apex Class Advanced DataSource Setup

    To configure an Advanced DataSource with an Apex Class, you must first create the Apex Class. Implement the SBLD.DataSourceService.Fetchable interface provided by the SmallBuilder Lists package in the Apex Class you want to use.

    Learn more about writing Apex Classes >


    🔸 Steps to Configure Apex Class Advanced DataSource

    1. Click the ➕ button to add a DataSource.

      Advanced DataSource Setup
    2. Search for and select the target Apex Class.

      Search Apex Class
    3. Configure the following attributes:

      Advanced DataSource for Apex Class Setup
    No.
    Name
    Description
    Required

    1

    Active

    Enable the DataSource. If not activated, it will not function during List configuration.

    2

    Description

    Add a description for the DataSource.

    3


    🔸 Steps to Configure Flow Advanced DataSource

    1. Click the ➕ button to add a DataSource.

      Advanced DataSource Setup
    2. Search for and select the target Flow.

      Search Flow
    3. Configure the following attributes:

      Advanced DataSource for Flow Setup
    No.
    Name
    Description
    Required

    1

    Active

    Enable the DataSource. If not activated, it will not function during List configuration.

    2

    Description

    Add a description for the DataSource.

    3

    Key Field

    Select a field in the List’s object that shares a common value with the key set in the Apex Class.

    ✔️

    4

    Parameters

    If the Apex Class requires field values from the List’s object, select and map those fields to be passed as parameters to the Apex Class.

    ✔️

    Input Variable

    Select variables to pass data to the Flow. This step is optional if no parameters are needed. 💡 The options displayed are the input variables (marked as “Available for input”) defined in the Flow.

    ✔️

    4

    Output Variable

    Select variables to retrieve data from the Flow’s result. 💡 The options displayed are the output variables (marked as “Available for output”) defined in the Flow.

    ✔️

    5

    Key Field

    Select a field in the List’s object that shares a common value with the output variable’s field in the Flow.

    ✔️

    Writing an Apex Class

    To use an Apex Class for the advanced DataSource setup, you must implement the SBLS.DataSourceService.Fetchable interface. This interface requires the implementation of the execute method, where you define the logic for processing data. The processed data, along with mapping information to the List, must be returned as an instance of the SBLS.DataSourceService.Result object.


    🔸 Example Code

    This example demonstrates retrieving inventory quantities from an external API based on product codes and mapping them to a virtual column (SBLS_Virtual1) in the List.

    Since the SBLS.DataSourceService.Fetchable interface is provided by the package, both the Apex Class and its methods must be declared as global to ensure external access.

    1

    Retrieve Records from the List

    Use params.gets() to access the records retrieved by the List.

    2


    🔸 SBLS.DataSourceService.Parameter

    This class provides access to the List’s records and fields selected during the builder configuration.

    Example Code

    Method

    List<SObject> gets()

    Returns the records retrieved from the List. If no parameters are added during the builder setup, this will return an empty value.


    🔸 SBLS.DataSourceService.Result

    The Result class holds all mapping information between the DataSource and the List. Actions added to this object define how the data is integrated.

    Example Code

    Method

    addAction(SBLS.DataSourceService.Action action)

    Adds an Action object containing mapping details to the Result.

    Parameter
    Type
    Value

    🔸 SBLS.DataSourceService.Action

    The Action class stores mapping information between the DataSource and the List.

    Example Code

    Method

    setKeyValue(Object keyValue)

    Sets the Key value from the DataSource that corresponds to the List’s Key.

    Parameter
    Type
    Value

    putSourceToTargetField(Object sourceValue, String targetFieldApiName)

    Maps the DataSource value to a field or virtual column in the List.

    Parameter
    Type
    Value
    Prepare DataSource Values
    • Simulate fetching data from an external API to retrieve inventory information.

    • In the example, inventory data is mapped using ProductCode as the key.

    3

    Generate the Result Object

    • Create an instance of SBLS.DataSourceService.Action for each mapping.

    • Set the DataSource value to the corresponding List field or virtual column using putSourceToTargetField.

    • Add each action to the .

    4

    Return the Result Object

    Return the Result object containing the mapping information for integration with the List.

    action

    SBLS.DataSourceService.Action

    An instance of the SBLS.DataSourceService.Action class that contains the mapping information between the List and the DataSource values.

    keyValue

    Object

    The Key value from the DataSource for mapping.

    sourceValue

    Object

    The value retrieved from the DataSource.

    targetFieldApiName

    String

    The API name of the List’s field or virtual column.

    DataSourceInventory.cls
    global class DataSourceInventory implements SBLS.DataSourceService.Fetchable {
        global SBLS.DataSourceService.Result execute(SBLS.DataSourceService.Parameter params) {
            // Retrieve records from the List
            List<SObject> records = params.gets();
        
            // Fetch DataSource values (e.g., inventory data) from an external API
            Map<String, Integer> inventoryData = new Map<String, Integer>(); 
            inventoryData.put('Product001', 10);
            inventoryData.put('Product002', 20);
    
            // Create the Result object
            SBLS.DataSourceService.Result result = new SBLS.DataSourceService.Result();
    
            // Map DataSource values to List records
            for (String productCode : inventoryData.keySet()) {
                SBLS.DataSourceService.Action action = new SBLS.DataSourceService.Action();
                action.setKeyValue(productCode); // Set the Key value for mapping
                action.putSourceToTargetField(
                    inventoryData.get(productCode), // DataSource value: inventory
                    'SBLS_Virtual1'                // Virtual column API name
                );
                result.addAction(action); // Add Action to the Result
            }
            
            return result; // Return the final Result
        }
    }
    global SBLS.DataSourceService.Result execute(SBLS.DataSourceService.Parameter params) {
        List<SObject> records = params.gets();
        ...
    }
    DataSourceInventory.cls
    ...
    SBLS.DataSourceService.Result result = new SBLS.DataSourceService.Result();
    for (String productCode : inventoryData.keySet()) {
        // Create an Action object to store mapping information
        SBLS.DataSourceService.Action action = new SBLS.DataSourceService.Action();
        action.setKeyValue(productCode); // Set the Key value for mapping
        action.putSourceToTargetField(
            inventoryData.get(productCode),  // DataSource value: inventory quantity
            'SBLS_Virtual1'                  // Target field: virtual column in the List
        );
        result.addAction(action); // Add Action to the Result
    }
    return result;
    DataSourceInventory.cls
    SBLS.DataSourceService.Result result = new SBLS.DataSourceService.Result();
    // Process each product code and inventory information from the DataSource
    for (String productCode : inventoryData.keySet()) {
        SBLS.DataSourceService.Action action = new SBLS.DataSourceService.Action();
        // Set the product code as the Key value to map with the List/Line Item
        action.setKeyValue(productCode);
        
        // Map inventory information to the Inventory__c field in the List/Line Item
        action.putSourceToTargetField(
            inventoryData.get(productCode),    // DataSource value: inventory
            'SBLS_Virtual1'                    // Virtual column API name
        );
        result.addAction(action); // Add mapping information
    }
    return result; // Return the final result
    <String, Integer> inventoryData = new Map<String, Integer>(); 
    inventoryData.put('Product001', 10);
    inventoryData.put('Product002', 20);
    SBLS.DataSourceService.Result
    // Create the Result object
    SBLS.DataSourceService.Result result = new SBLS.DataSourceService.Result();
    
    // Map DataSource values to List records
    for (String productCode : inventoryData.keySet()) {
        SBLS.DataSourceService.Action action = new SBLS.DataSourceService.Action();
        action.setKeyValue(productCode); // Set the Key value for mapping
        action.putSourceToTargetField(
            inventoryData.get(productCode), // DataSource value: inventory
            'SBLS_Virtual1'                // Virtual column API name
        );
        result.addAction(action); // Add Action to the Result
    }