# Salesforce Import Integration You can connect Salesforce with Treasure Data for greater control over your Salesforce data and better integration with the other business applications in your marketing and sales operations stack. Integrating Salesforce with Treasure Data makes it easy to: - **Add new features to Salesforce.** For example, you can prevent churn by tracking web usage and receiving alerts when customers' product usage declines. - **Use Salesforce data to improve other parts of your marketing stack.** For example, you can increase your Facebook Ads ROI by automatically removing new customers from your Facebook Custom Audiences. For sample workflows on importing data from Salesforce, go to [Treasure Boxes](https://github.com/treasure-data/treasure-boxes/tree/master/td_load/sfdc). If you don't have a Treasure Data account, [contact us](https://www.treasuredata.com/contact_us/) so we can set you up. ## Limitations - **SOQL:** This configuration allows a custom SOQL (Salesforce Object Query Language) to query and filter data. With SOQL, you can retrieve the data from a single object or multiple objects that are related to each other. You can pick specific columns and filter or sort the output with your conditional statement. As a limitation, our data connector doesn't support SOQL syntax such as *count() FROM Object* and *SELECT * from salesforceObject*. - **Bulk API limits:** Bulk API offers faster ingestion but also has a limitation of 10,000 batch allocations within 24 hours. If your target is large, your entire available batch allocation might be consumed, eventually causing your job to fail. If you try to use the Bulk API, and the result is ingesting all records, consider enabling the **synchronous transfer-only** option and using REST API. REST API avoids the batch allocation limitation but might be slower. - **SOQL with the LIMIT clause:**  SOQL queries do not function properly with the LIMIT clause in the Bulk API mode. The Bulk API is specifically designed for handling large volumes of data. To use the LIMIT clause, it is imperative to utilize the REST API instead. - **OAuth**: OAuth doesn't support custom domains. Thus if you are using a custom domain, please use credentials as the authentication method. ## Support SFDC import supports these authentication types: - Credential - **Enabled username & password flow:** SETTINGS → Identity → OAuth and OpenID Connect Settings → Allow OAuth Username-Password Flows (turn it on) - **OAuth Policies:** PLATFORM TOOLS → App → Connected Apps → Manage Connected Apps → Choose App → Edit Policies → Permitted Users (selected: All users may self-authorize) - OAuth Using **Session ID for authentication** is not supported for import. The Session ID is supported only for [Salesforce Export Integration](/int/salesforce-export-integration). ## Connect to Salesforce Using TD Console Connecting to Salesforce using the TD Console is quick and easy. Alternatively, you can create a Salesforce connection using the command line. The import integration supports credentials; you need a client ID and client secret to authenticate using credentials. ## Allow TD to Access Salesforce using Salesforce. These instructions guide you to locate the client ID and client secret necessary to authenticate using credentials. This is the guide for Lightning Experience UI. 1. Go to **Setup** > **Apps** > **App Manager**. 2. Select **New Connected App.** 3. Set some values and check to **Enable OAuth Settings**. Then, grant OAuth permission scope.![](/assets/oauth_setting.7fc14f2db75ac78c8f2ac3de705e2fab32f3eb4f5209915dc51d425433ace4aa.3074136a.png) 4. Click **Save**. Activation can take up to 10 minutes. 5. Go to **Setup** > **Apps** > **App Manager**. 6. Locate the connected app, click **▼**, and then select **View**. ![](/assets/connected_app.9e63c75823ffc511c1015194c179433b8099f9f358711098a1699ee6e4f1bed8.3074136a.png) 7. Write down or copy your **Consumer Key** (client_id) and **Consumer Secret** (client_secret). ![](/assets/crient_secret.34a2b6324e27f53438e82f7a396c84b094c94c190bc093a92ddbf504fc0c7bd3.3074136a.png) ## Create New Connection in TD Console 1. Open **TD Console**. 2. Navigate to **Integrations Hub** > **Catalog** and search for **Salesforce** 3. Choose one of the following: Authenticate with Credentials 1. To authenticate with your credentials, enter your username (email) and password and your Client ID, Client Secret, and Security Token. 2. In the dialog box, enter [login.salesforce.com](https://login.salesforce.com/) as the login URL. Remove unnecessary letters from the Login URL parameter. ![](/assets/image-20200703-001720.af452b1f9ec571b64403178a495107a980e547d907f48f30614cf4b53843e7ed.d00a286f.png) Authenticate with OAuth ![](/assets/image-20201029-003333.3c371aa8231f40a349fe8bb1f49641b0c7abe05195705af5e11af1a6027b1d1c.d00a286f.png) 1. Select **Continue.** 2. Give your connection a descriptive name and select **Create Connection.** ## Validate Your Salesforce Connection To validate the user permission, make sure to use Salesforce to validate the following: - Authority: check the Salesforce import integration connection steps. - Allowed access to Salesforce from Treasure Data: sometimes configuring this requires knowing and configuring your TD static IP address. Contact support if you need the static IP address information. Without properly configured authority and access, you might encounter access restriction errors. For example: ``` Response not 2xx: 400 Bad Request {"error":"invalid_grant","error_description":"authentication failure"} ``` Learn more about [Object and Field Permissions for Salesforce CRM in Data Cloud](https://help.salesforce.com/s/articleView?id=sf.c360_a_enable_user_permissions_external_salesforce_org.htm&type=5). ## Transfer Your Salesforce Account Data to Treasure Data After creating the authenticated connection, you are automatically taken to Authentications. 1. Search for the connection you created. 2. Select **New Source**. 3. Type a name for your **Source** in the Data Transfer field**.** ![](/assets/image-20200710-205832.2c1ff801d788249554ab89bd4e24919ef34ff56a9aa225d3aff6de57181e008b.d00a286f.png) 4. Click **Next**. 5. Edit the following parameters: ![](/assets/image-20200710-210028.37482785cab2d316edadd716f5eb88ee867bd570ec1f508e025977427fb834c5.d00a286f.png) | **Parameters** | **Description** | | --- | --- | | **Source** | Name of the object you want to import | | **Include deleted records** | Enables including deleted records | | **Use synchronous transfer only** | Enables synchronous transfer using REST API | | **Incremental** | Imports only new data since the last import | ### **Data Settings** 1. Select **Next**. The Data Settings page opens. 2. You can edit the SOQL query, WHERE conditions, and Schema settings here. 3. Optionally, skip this page of the dialog. ![](/assets/image-20200710-211039.6d38d12794407b568ad98bca8ab96943b9c044037c5e15c8dc249c258f62d7c4.d00a286f.png) ### Data Preview You can see a [preview](/products/customer-data-platform/integration-hub/batch/import/previewing-your-source-data) of your data before running the import by selecting Generate Preview. Data preview is optional and you can safely skip to the next page of the dialog if you choose to. 1. Select **Next**. The Data Preview page opens. 2. If you want to preview your data, select **Generate Preview**. 3. Verify the data. ### Data Placement For data placement, select the target database and table where you want your data placed and indicate how often the import should run. 1. Select **Next.** Under Storage, you will create a new or select an existing database and create a new or select an existing table for where you want to place the imported data. 2. Select a **Database** > **Select an existing** or **Create New Database**. 3. Optionally, type a database name. 4. Select a **Table**> **Select an existing** or **Create New Table**. 5. Optionally, type a table name. 6. Choose the method for importing the data. - **Append** (default)-Data import results are appended to the table. If the table does not exist, it will be created. - **Always Replace**-Replaces the entire content of an existing table with the result output of the query. If the table does not exist, a new table is created. - **Replace on New Data**-Only replace the entire content of an existing table with the result output when there is new data. 7. Select the **Timestamp-based Partition Key** column. If you want to set a different partition key seed than the default key, you can specify the long or timestamp column as the partitioning time. As a default time column, it uses upload_time with the add_time filter. 8. Select the **Timezone** for your data storage. 9. Under **Schedule**, you can choose when and how often you want to run this query. #### Run once 1. Select **Off**. 2. Select **Scheduling Timezone**. 3. Select **Create & Run Now**. #### Repeat Regularly 1. Select **On**. 2. Select the **Schedule**. The UI provides these four options: *@hourly*, *@daily* and *@monthly* or custom *cron*. 3. You can also select **Delay Transfer** and add a delay of execution time. 4. Select **Scheduling Timezone**. 5. Select **Create & Run Now**. After your transfer has run, you can see the results of your transfer in **Data Workbench** > **Databases.** ## FAQ ### Q. Imported records contain. `attributes` column, but our SFDC doesn't have such a parameter. What is this? A. This is a column that SFDC import integration automatically created. It includes the API request URI and a target object.