Skip to main content
Skip table of contents

Create a Data Source

Administrators can create a data source so a Community Hub component can create, display, modify, or delete data. A Data source can manipulate data using a SOQL query record, flow, or Apex class.

Using a Query Record

  1. In the Force.com App Menu, select Community Hub Setup.
  2. In the tab bar, click Data Sources.
  3. Click New Data Source.
  4. In Name, enter an easily recognizable term to identify this data source.

    If you have multiple Community Hubs, and intend to use a similar data source in each, we recommend you name each after the Community Hub in which it will be used, so you can distinguish them.

  5. In Description, enter a description of what the data source does.
  6. In Class, enter SOQLDataSource.
  7. In Context, begin typing the name of the SOQL query record you would like to use and select it from the list of results.

    If you have multiple Community Hubs, keep in mind whether the SOQL query should filter for only records associated with the entity(s) for the Community Hub in which this data source will be used, or if you want to return records from all entities.

  8. Click Save.

Using a Flow

  1. In the Force.com App Menu, select Community Hub Setup.
  2. In the tab bar, click Data Sources.
  3. Click New Data Source.
  4. In Name, enter an easily recognizable term to identify this data source.

    If you have multiple Community Hubs, and intend to use a similar data source in each, we recommend you name each after the Community Hub in which it will be used, so you can distinguish them.

  5. In Description, enter a description of what the data source does.

  6. In Class, enter the name of one of these Apex classes:

    ApexDescription
    FlowDataSourceUse this Apex class to return data to be used by the flow.
    NewSObjectFlowDataSourceUse this Apex class to insert new data with the flow.

    If you have multiple Community Hubs, keep in mind this Apex class returns records from all entities.

  7. In Context, enter the name of the flow.
  8. In sObject Type, enter the API name of the sObject to be used by the flow.
  9. Click Save.

Configuring a Flow For Use in a Data Source

This example will step you through the process of creating a Flow for use in a Data Source, using the following elements as an example:

    • 1 Variable - CurrentAccountId (Data Type: Text)

    • 1 SObject Variable - InputSObject (Type: Experience)

    • 1 SObject Collection Variable - OutputData (Type: Experience)

    • 2 Assignments - Set Experience and Add To Output.

  1. From Setup, Search and Access "Flow" | New Flow
  2. Set any default values on your InputSObject. For this example, the CurrentAccountId is used for the Account lookup.

  3. Add the InputSObject variable into the OutputData collection for use in our data source.
  4. Hover over the Set Experience node and, in the upper right corner, select the green circle with a down arrow icon to set as the Start Element and connect the Set Experience node to the Add To Output node.
  5. Save and Activate the flow

Using an Apex Class

  1. In the Force.com App Menu, select Community Hub Setup.
  2. In the tab bar, click Data Sources.
  3. Click New Data Source.
  4. In Name, enter an easily recognizable term to identify this data source.

    If you have multiple Community Hubs, and intend to use a similar data source in each, we recommend you name each after the Community Hub in which it will be used, so you can distinguish them.

  5. In Description, enter a description of what the data source does.

  6. In Class, enter the name of Apex class you want the data source to use.

    If you have multiple Community Hubs, keep in mind whether the Apex class should filter for only records associated with the entity(s) for the Community Hub in which this data source will be used, or if you want to return records from all entities.

  7. If you need to provide the Apex class any contextual data, in Context, enter the contextual data.
  8. If you need to provide the Apex class the sObject type it should reference, in sObject Type, enter the API name of the object.
  9. Click Save.
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.