# Salesforce Commerce Cloud Export Integration Salesforce Commerce Cloud (SFCC) is an e-commerce solution for B2C (business to consumer) and B2B (business to business) customers. This connector helps to - Synchronize customer profiles on TD Console to the Customer Lists on the SFCC platform. - ​Assign customers to or remove customers from the static Customer Groups on the SFCC platform. ## Prerequisites - Basic Knowledge of Treasure Data - Basic knowledge of Salesforce Commerce Cloud - Basic knowledge of Open Commerce Cloud API - Have an API Client created on the Commerce Cloud Account Manager System. Further details can be found [here](/int/salesforce-commerce-cloud-export-integration#h2_1482152047) ## Limitations - The application secret should not contain the `%`  character. Due to an internal issue with the SFCC authentication server, any secret containing the `% character is not able to authenticate.` - The connector will send the customer attributes as-is without validating them. Data validation is on the SFCC side. - To synchronize customer profiles to the SFCC Customer List, the list must exist on SFCC before the job execution. - A large volume of data may cause low performance. ## Use the TD Console ### Create a New Connection You must create and configure the data connection on TD Console before running your query. As part of the data connection, you provide authentication to access the integration following the below steps ![](/assets/salesforce-commerce-cloud-export-integration-2024-06-20.63ef2448dd32726a66ef34f3d776726b55e61dfeb03b58fe1653badfceb9f382.fe495661.png) 1. Open **TD Console** 2. Navigate to **Integrations Hub > Catalog** 3. Search for and select **Salesforce Commerce Cloud** 4. Select **Create Authentication**, and provide the credential information for the integration as described below 5. Select **Continue,**enter a name for the Authentication, and select **Done**. ### Authentication Fields | **Field** | **Description** | | --- | --- | | **API Client ID** | The API Client ID is generated by following the [Create and configure an API Client](/int/salesforce-commerce-cloud-export-integration#h2_1482152047) procedure | | **API Client Password** | The password of the API Client | | **Base URI** | URL for accessing your Business Manager Application. Example value:  https://xxxx.commercecloud.salesforce.com/ | ### Configure a Query Result for Export The TD Console supports multiple ways to export data. Please follow the below steps to export data from the Data Workbench. 1. Navigate to **Data Workbench > Queries.** 2. Select **New Query**, and define your query. 3. Select **Export Results** to configure the data exporting. 4. Select an existing SFCC authentication or create a new one following the above section. 5. Configure the exporting parameters as described below, and select **Done.** - Configuration Parameters | Field | Description | | --- | --- | | Data target | - Select **Customer List** to manipulate customer profiles on the target platform, including creating new customer profiles, updating profiles, and deleting profiles. - Select **Customer Group** to assign customers to or remove customers from the specific static Customer Groups. | | Operation mode | ​With the **Customer List** data target, select one of the supported operating modes that follow:- **Create**: create new customer profiles. - **Update**: Update the customer profile attributes determined in the *customer_no* column. - **Upsert**: Overwrite the customer profiles determined in the *customer_no* column. If they don't exist, new profiles are created. - **Delete**: Delete customer profiles determined in the *customer_no* column. With the **Customer Group** data target, select one of the support operating modes that follow: - **Add**: Assign customers determined in the *customer_no* column to the specific Customer Group. - **Remove**: Un-assign customers determined in the *customer_no* column from the specific Customer Group. - **Replace**: The specified Customer Group will be deleted, and then a new one will be created with the same ID and customer profiles added. | | Customer list ID | Required in case of the *Customer List* data target. The ID of a predefined Customer List needs to be provided. Otherwise, the query result must include a column named *customer_list_id.* | | Skip empty/null fields | (Applied only for the *Customer List* data target) When unchecked, empty, or null, attributes (columns) will be sent to SFCC. Consequently, those attributes on SFCC will be cleared (be overwritten by an empty value). The default is checked, in which attributes that are empty or null will not be sent to SFCC. | | Site ID | Required in case of the *Customer Group* data target. The ID of the *site* the target Customer Group belongs. | | Customer group ID | Required in case of the *Customer Group* data target. The ID of a static Customer Group. If not exist, a new one will be created | | Customer group name | (Optional. Applied only for the *Customer Group* data target.) The group name will be used in case the specified Customer Group doesn't exist. | | Thread count | The number of concurrent upload jobs ranges from 2 to 40. | Customer attribute overwriting of the Customer List data target - Use **Update** mode to update some selected attributes of the existing customer profiles. If `Skip empty/null fields` is checked, empty or null attributes will not be exported, and the existing values on SFCC will stay unchanged. - Use **Upsert** mode when you want to overwrite all attributes. This means that the existing customer profiles will be replaced by those included in the query result, and attributes that are not included will be emptied. Profiles that do not exist will be created anew. | ### Define your query to synchronize customer profiles to the **Customer Lists** - Your query must include the **customer_no** column to indicate which customer profiles are synchronized. - If the query intention is to update multiple Customer Lists, a column named **customer_list_id** can be included to indicate the target lists - For other customer attributes, please refer to the SFCC documentation. All attributes will be sent as-is without any validation | **Column** | **Description** | **Mandatory** | | --- | --- | --- | | customer_list_id | If it is not empty/null, it defines the ID of the Customer List, where the customer attributes on the row will be updated. Otherwise, the Customer List filled in the Configuration screen will be taken into account. | Optional | | customer_no | SFCC Customer Number. it is not required in the Create mode. | **Required** | | Credentials | Credential information is required in the Create mode. Please refer [here](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/ocapi-data-api?meta=type%3Acredentials) for more details. | Optional | | Customer attributes | Refer [here](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/ocapi-data-api?meta=type%3Acustomer) for the list of supported attributes. | Optional | | Customer address | Refer [here](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/ocapi-data-api?meta=type%3Acustomer_address) for the list of supported attributes. | Optional | ### Define your Query to Assign/Remove Customers to **Customer Groups** To assign (or remove) customers to (from) a Customer Group, the only required column in your query is the **customer_no** column. ### (Optional) Schedule Query Export Jobs You can use Scheduled Jobs with Result Export to periodically write the output result to a target destination that you specify. Treasure Data's scheduler feature supports periodic query execution to achieve high availability. When two specifications provide conflicting schedule specifications, the specification requesting to execute more often is followed while the other schedule specification is ignored. For example, if the cron schedule is `'0 0 1 * 1'`, then the 'day of month' specification and 'day of week' are discordant because the former specification requires it to run every first day of each month at midnight (00:00), while the latter specification requires it to run every Monday at midnight (00:00). The latter specification is followed. #### Scheduling your Job Using TD Console 1. Navigate to **Data Workbench > Queries** 2. Create a new query or select an existing query. 3. Next to **Schedule**, select None. ![](/assets/image2021-1-15_17-28-51.f1b242f6ecc7666a0097fdf37edd1682786ec11ef80eff68c66f091bc405c371.0f87d8d4.png) 4. In the drop-down, select one of the following schedule options: ![](/assets/image2021-1-15_17-29-47.45289a1c99256f125f4d887e501e204ed61f02223fde0927af5f425a89ace0c0.0f87d8d4.png) | Drop-down Value | Description | | --- | --- | | Custom cron... | Review [Custom cron... details](#custom-cron-details). | | @daily (midnight) | Run once a day at midnight (00:00 am) in the specified time zone. | | @hourly (:00) | Run every hour at 00 minutes. | | None | No schedule. | #### Custom cron... Details ![](/assets/image2021-1-15_17-30-23.0f94a8aa5f75ea03e3fec0c25b0640cd59ee48d1804a83701e5f2372deae466c.0f87d8d4.png) | **Cron Value** | **Description** | | --- | --- | | `0 * * * *` | Run once an hour. | | `0 0 * * *` | Run once a day at midnight. | | `0 0 1 * *` | Run once a month at midnight on the morning of the first day of the month. | | "" | Create a job that has no scheduled run time. | ``` * * * * * - - - - - | | | | | | | | | +----- day of week (0 - 6) (Sunday=0) | | | +---------- month (1 - 12) | | +--------------- day of month (1 - 31) | +-------------------- hour (0 - 23) +------------------------- min (0 - 59) ``` The following named entries can be used: - Day of Week: sun, mon, tue, wed, thu, fri, sat. - Month: jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec. A single space is required between each field. The values for each field can be composed of: | Field Value | Example | Example Description | | --- | --- | --- | | A single value, within the limits displayed above for each field. | | | | A wildcard `'*'` to indicate no restriction based on the field. | `'0 0 1 * *'` | Configures the schedule to run at midnight (00:00) on the first day of each month. | | A range `'2-5'`, indicating the range of accepted values for the field. | `'0 0 1-10 * *'` | Configures the schedule to run at midnight (00:00) on the first 10 days of each month. | | A list of comma-separated values `'2,3,4,5'`, indicating the list of accepted values for the field. | `0 0 1,11,21 * *'` | Configures the schedule to run at midnight (00:00) every 1st, 11th, and 21st day of each month. | | A periodicity indicator `'*/5'` to express how often based on the field's valid range of values a schedule is allowed to run. | `'30 */2 1 * *'` | Configures the schedule to run on the 1st of every month, every 2 hours starting at 00:30. `'0 0 */5 * *'` configures the schedule to run at midnight (00:00) every 5 days starting on the 5th of each month. | | A comma-separated list of any of the above except the `'*'` wildcard is also supported `'2,*/5,8-10'`. | `'0 0 5,*/10,25 * *'` | Configures the schedule to run at midnight (00:00) every 5th, 10th, 20th, and 25th day of each month. | 1. (Optional) You can delay the start time of a query by enabling the Delay execution. ### Execute the Query Save the query with a name and run, or just run the query. Upon successful completion of the query, the query result is automatically exported to the specified destination. Scheduled jobs that continuously fail due to configuration errors may be disabled on the system side after several notifications. (Optional) You can delay the start time of a query by enabling the Delay execution. ## Activate a Segment in Audience Studio You can also send segment data to the target platform by creating an activation in the Audience Studio. 1. Navigate to **Audience Studio**. 2. Select a parent segment. 3. Open the target segment, right-mouse click, and then select **Create Activation.** 4. In the **Details** panel, enter an Activation name and configure the activation according to the previous section on Configuration Parameters. 5. Customize the activation output in the **Output Mapping** panel. ![](/assets/ouput.b2c7f1d909c4f98ed10f5300df858a4b19f71a3b0834df952f5fb24018a5ea78.8ebdf569.png) - Attribute Columns - Select **Export All Columns** to export all columns without making any changes. - Select **+ Add Columns** to add specific columns for the export. The Output Column Name pre-populates with the same Source column name. You can update the Output Column Name. Continue to select **+ Add Columns**to add new columns for your activation output. - String Builder - **+ Add string** to create strings for export. Select from the following values: - String: Choose any value; use text to create a custom value. - Timestamp: The date and time of the export. - Segment Id: The segment ID number. - Segment Name: The segment name. - Audience Id: The parent segment number. 1. Set a **Schedule**. ![](/assets/snippet-output-connector-on-audience-studio-2024-08-28.a99525173709da1eb537f839019fa7876ffae95045154c8f2941b030022f792c.8ebdf569.png) - Select the values to define your schedule and optionally include email notifications. 1. Select **Create**. If you need to create an activation for a batch journey, review [Creating a Batch Journey Activation](/products/customer-data-platform/journey-orchestration/batch/creating-a-batch-journey-activation). ## (Optional) Export Integration Using the CLI The [TD Toolbelt](https://toolbelt.treasuredata.com/) can trigger the Query Result exporting from a CLI. You need to specify the parameters for the exporting job as the `--result` option of the `td query` command. For more information, please refer to [this article](https://docs.treasuredata.com/articles/pd/querying-and-importing-data-to-treasure-data-from-the-command-line). The format of the option is JSON and the general structure is as follows. - Case: data_target is customer_list ```json {"type": "salesforce_commerce_cloud", "client_id": "client_id", "client_secret": "client_secret", "base_url": "https://your link.commercecloud.salesforce.com", "data_target": "customer_list", "operation_mode": "create,update,delete,upsert", "customer_list_id": "customer_list_id", "skip_empty_fields": true, "thread_count": 2}Case: data_target is customer_group{ "type": "salesforce_commerce_cloud", "client_id": "client_id", "client_secret": "client_secret", "base_url": "https://your link.commercecloud.salesforce.com", "data_target": "customer_list", "customer_group_operation_mode": "add,remove,replace", "site_id": "your site id", "customer_group_id": "your customer group id", "customer_group_name": "your customer group name", "thread_count": 2} ``` ### CLI Parameters | Name | Description | Value | Default Value | Required | | --- | --- | --- | --- | --- | | data_target | Ref *data_target* in Configuration Parameters section | List of options:1. customer_list 2. customer_group | customer_group | YES | | td_authentication_id | This is the id of the exsiting SFCC authentication on TD console. PS: when using td_authentication_id, we don't need to declare the client_id & client_secret. Because TD system will get those info by td_authentication_id | Number | null | NO | | client_id | The client_id that get from SFCC. PS: TD system will ignore this value when td_authentication_id is null. | String | null | YES (when td_authentication_id is null) | | client_secret | The client_secret that get from SFCC. PS: TD system will ignore this value when td_authentication_id is null. | String | null | YES (when td_authentication_id is null) | | base_url | Ref *base_url* in Configuration Parameters section | String | null | YES | | operation_mode | Ref *operation_mode* in *Configuration Parameters section.* The operation_mode only use when the **data_target** is **customer_list**. | Options:1. customer_list 2. customer_group | customer_list | YES (when *data_target* is ***customer_list***) | | customer_list_id | Ref *customer_list_id* in *Configuration Parameters section.* The operation_mode only use when the **data_target** is **customer_list**. | String | null | YES (when *data_target* is ***customer_list***) | | skip_empty_fields | The indicator flag that help the connector decide to ignore the fields that have value are empty or null. | Boolean | true | NO | | customer_group_operation_mode | The operation_mode only use when the **data_target** is **customer_group**. Which action will be apply for customer_group. | Options:1. add: Assign the customer_no to a specific ***customer_group_id***. 2. remove: remove the customer_no to a specific ***customer_group_id***. 3. replace: remove all the members in a specific group and assign the customer_no to that list. | Add | YES (when *data_target* is ***customer_group***) | | site_id | Ref ***site_id*** in *Configuration Parameters section.* | String | null | YES (when *data_target* is ***customer_group***) | | customer_group_id | Ref ***customer_group_id*** in *Configuration Parameters section.* | String | null | YES (when *data_target* is ***customer_group***) | | customer_group_name | Ref ***customer_group_name*** in *Configuration Parameters section.* | String | empty | NO | ### Example usage - Create the new customer ```bash td --database luan_db --wait "SELECT customer_list_id,first_name,last_name,birthday,company_name,email,fax,gender,job_title,phone_business,phone_home,phone_mobile,second_name,credentials FROM (VALUES ('site_1','fname_201','lname_1','1990-05-12','Test Company','test201@test.com','84111111201',1,'Sr Software','84111111201','84111111201','84111111201','Ryan','{\"enabled\":true,\"locked\":false,\"login\":\"login_url_1_100001.csv\"}')) tbl(customer_list_id,first_name,last_name,birthday,company_name,email,fax,gender,job_title,phone_business,phone_home,phone_mobile,second_name,credentials)" \--type presto \--result '{"type":"salesforce_commerce_cloud","td_authentication_id": 2837,"base_url":"https://zzvt-003.dx.commercecloud.salesforce.com","operation_mode":"create","customer_list_id":"static_g_1","skip_invalid_record":true,"thread_count":2}' ``` - Update the existing customer ```bash td --database luan_db --wait "SELECT customer_list_id,customer_no,first_name,last_name,credentials FROM (VALUES ('site_1','00000001','fname_1_updated','','{\"enabled\":true,\"locked\":false,\"login\":\"login_url_1_100001.csv\"}')) tbl(customer_list_id,customer_no,first_name,last_name,credentials)" \--type presto \--result '{"type":"salesforce_commerce_cloud","data_target": "customer_list","td_authentication_id": 2837,"base_url":"https://zzvt-003.dx.commercecloud.salesforce.com","operation_mode":"update","customer_list_id":"static_g_1","skip_invalid_record":true,"thread_count":2}' ``` - Assign customer to a specific customer group ```bash td --database luan_db --wait "SELECT customer_no FROM (VALUES ('00000001')) tbl(customer_no)" \--type presto \--result '{"type":"salesforce_commerce_cloud","data_target": "customer_group","td_authentication_id": 2837,"base_url":"https://zzvt-003.dx.commercecloud.salesforce.com","customer_group_operation_mode":"add","site_id":"site_1", "customer_group_id": "static_customer_group_1","thread_count":2}' ``` ## (Reference) Create and configure an API Client This section explains at a high level how to obtain credentials and configure necessary permissions (if any) to use the SFCC API. The detailed steps might be changed by Salesforce without any in-advance notice. ### Create an API Client on the SFCC Account Manager System 1. Navigate and log in to the [SFCC Account Manager](https://account.demandware.com/dw/account/Home#/) 2. Select **API Client** ![](/assets/2.be4fec22b1256686095d473c7740365177027c0ed2e9ffb8b6c407a080314b68.fe495661.png) 1. Select **Add API Client** ![](/assets/3.8889c5457f7f0dc1e4bafc2ad44bac3bbe46fdd7e7fd1d12800d528888272d6e.fe495661.png) 1. Type values for Display Name, Password, Confirm Password, and select **Access Control** to enable it 2. In the **Organizations** area, select your organization 3. In the Roles area, select **Add** 4. Select the appropriate roles, and select **Add** 5. Scroll to the **Token Endpoint Auth Method** section 6. Select the Auth method and the token format like the one below, and select **Save** ![](/assets/6.caff70407f1f595dd5532a653e7edfde4981c4ce8eead310e35bc53cd184cd1e.fe495661.png) 1. Note down the **API Client ID** and **Password** to create a new Authentication for the SFCC integration on the TD Console ### Configure the API Client to access your SFCC instance These steps allow the created API Client to modify data on your SFCC instance using the Open Commerce API features 1. Open Business Manager (https://{YOUR_INSTANCE_URL}.commercecloud.salesforce.com/on/demandware.store/Sites-Site/default/ViewApplication-DisplayWelcomePage) 2. Select **Administration** >> **Open Commerce API Settings** ![](/assets/8.22f4966f9acc62700502855a8614f8279229742bef4096f8e623c4ee65c4de85.fe495661.png) 1. Select Data in the **Select Type** drop-down list ![](/assets/9.c1b302b94a60b61d7fcf3e0bd611ed1efbbab4856fb53942f53957ac5716e6f3.fe495661.png) 1. On the configuration string of the Data API, make sure the WRITE permission is set: **"write_attributes": "(**)"** 2. Select  Global (organization-wide) in the **Select Context** drop-down list 3. Select **Save**, and the permission of the API Client will be applied in a few minutes Your API Client is ready to be used in the Salesforce Commerce Cloud integration ## Related articles - The Result Export can be [scheduled](https://docs.treasuredata.com/articles/pd/scheduling-jobs-using-td-console) to upload data to a target destination periodically - All import and export integrations can be added to a [TD Workflow](https://docs.treasuredata.com/articles/pd/about-treasure-workflow). The **td** data operator can be used to export a query result to a specified connector. For more information, see [Reference for Treasure Data Operators](https://docs.treasuredata.com/articles/pd/reference-for-treasure-data-operators/a/h1_76525622) - [Open Commerce Cloud API](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-commerce-ocapi/get-started-with-ocapi.md)