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
- In the Force.com App Menu, select Community Hub Setup.
- In the tab bar, click Data Sources.
- Click New Data Source.
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.
- In
Description
, enter a description of what the data source does. - In
Class
, enterSOQLDataSource
. 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.
- Click Save.
Using a Flow
- In the Force.com App Menu, select Community Hub Setup.
- In the tab bar, click Data Sources.
- Click New Data Source.
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.
In
Description
, enter a description of what the data source does.In
Class
, enter the name of one of these Apex classes:Apex Description FlowDataSource
Use this Apex class to return data to be used by the flow. NewSObjectFlowDataSource
Use 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.
- In
Context
, enter the name of the flow. - In
sObject Type
, enter the API name of the sObject to be used by the flow. - 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.
- From Setup, Search and Access "Flow" | New Flow
Set any default values on your InputSObject. For this example, the CurrentAccountId is used for the Account lookup.
- Add the InputSObject variable into the OutputData collection for use in our data source.
- 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.
- Save and Activate the flow
Using an Apex Class
- In the Force.com App Menu, select Community Hub Setup.
- In the tab bar, click Data Sources.
- Click New Data Source.
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.
In
Description
, enter a description of what the data source does.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.
- If you need to provide the Apex class any contextual data, in
Context
, enter the contextual data. - If you need to provide the Apex class the sObject type it should reference, in
sObject Type
, enter the API name of the object. - Click Save.