Salesforce (Sales & Service Cloud) integration

Google Cloud Cortex Framework transforms raw Salesforce Sales Cloud and Salesforce Service Cloud objects into analytics-ready BigQuery tables by using the prebuilt cortex.sfdc data foundation and data product modules. To deploy these prebuilt modules, you replicate standard Salesforce objects (SObjects) into a raw BigQuery dataset where generated Dataform pipelines deduplicate changes and apply business logic.

If you want to query unified customer profiles or Data Model Objects (DMOs) from Salesforce Data 360 (formerly Data Cloud) without copying data, see Salesforce Data 360 integration.

Replication options

You can populate the raw Salesforce dataset in BigQuery by using either of the following approaches:

  • BigQuery Data Transfer Service for Salesforce (recommended): Built-in Google Cloud connector that schedules recurring full or incremental transfers from Salesforce into BigQuery (supporting Salesforce Bulk API v1 version 64.0) without third-party infrastructure. To set up a transfer job, see the Salesforce transfer guide.
  • Third-party ELT or CDC connectors: Any replication tool that lands raw Salesforce SObjects in BigQuery while preserving standard Salesforce object names, column names, data types, and system audit fields.

BigQuery Data Transfer Service configuration hints

When configuring BigQuery Data Transfer Service for Salesforce transfer jobs for the supported SObjects, apply the following settings:

  • Split the SObjects across transfer configurations (10-object limit): BigQuery Data Transfer Service recommends a maximum of 10 objects (assets) per transfer configuration and at most 10 simultaneous transfer runs to avoid Salesforce Bulk API processing delays or skipped runs. Group your transfer configurations to match the default hourly and daily Dataform tags in table_settings.default.yaml:
    • Hourly incremental transfers (hourly tag, CDC SObjects): Case, CaseComment, CaseHistory, EmailMessage, Event, and Task.
    • Daily incremental transfers (daily tag, CDC SObjects, split across two configurations of up to 10 objects): Account, Asset, Campaign, CampaignMember, Contact, DatedConversionRate, Group, Lead, Opportunity, OpportunityContactRole, OpportunityHistory, OpportunityLineItem, Pricebook2, PricebookEntry, Product2, Profile, User, and UserRole.
    • Daily full-snapshot transfers (isCdc: false, reference SObjects): Configure CurrencyType, Organization, and RecordType with Full ingestion (ingestionType: "full").
  • Select watermark and primary key columns for incremental transfers: For the incremental SObjects (ingestionType: "incremental"), set watermarkColumns to SystemModstamp for SObjects and to CreatedDate for CaseHistory (which is append-only and lacks SystemModstamp). When using Upsert write mode, set primaryKeys to ["Id"] for each object.
  • Match the DTS write mode (WRITE_MODE_APPEND or WRITE_MODE_UPSERT) to your foundation external setting:
    • Standard foundation mode (external: false, default): Works with raw landing datasets populated using Append write mode (writeMode: "WRITE_MODE_APPEND") or Upsert write mode (writeMode: "WRITE_MODE_UPSERT"). The cortex.sfdc.foundations.sfdc module deduplicates incremental batches by Id, normalizes raw PascalCase DTS table names into snake_case foundation tables (CampaignMember to campaign_member, OpportunityLineItem to opportunity_line_item, Pricebook2 to pricebook2, RecordType to record_type), and attaches curated table and column descriptions from annotations/*.yaml (because raw DTS transfers don't replicate Salesforce field descriptions).
    • External deduplicated mode (external: true, omitting dataTargetId): When a landing dataset already maintains deduplicated records in BigQuery (such as a WRITE_MODE_UPSERT landing dataset like SFDC_RAW_UPSERT or an external pipeline), setting external: true skips foundation .js model generation and registers the dataSourceId tables directly as Dataform sources (definitions/sources/). Because prebuilt cortex.sfdc.products.* models reference snake_case foundation table names (account, opportunity_line_item, currency_type), keep external: false when landing raw PascalCase DTS tables for prebuilt data products.

Before you begin

Before you run uv run cortex-build for Salesforce modules, complete the following prerequisites:

  1. Enable the BigQuery (bigquery.googleapis.com) and Dataform (dataform.googleapis.com) APIs in your target project, and enable the BigQuery Data Transfer Service API (bigquerydatatransfer.googleapis.com) if you use BigQuery Data Transfer Service for Salesforce.
  2. Create a raw BigQuery dataset (for example, cortex_sfdc_raw) in the same BigQuery location as your target foundation and data product datasets.
  3. Replicate the Salesforce SObjects required by your selected modules into the raw dataset. For the complete list of supported SObjects, see Data foundation tables for Salesforce. If your Salesforce organization uses multiple currencies, replicate CurrencyType (and DatedConversionRate when Advanced Currency Management is active) and include the CurrencyIsoCode field on all SObjects that store monetary amounts so downstream currency conversions resolve accurately.
  4. Grant the required Identity and Access Management (IAM) roles across your source, build, and target projects:
    • CLI build principal (uv run cortex-build): BigQuery Data Viewer (roles/bigquery.dataViewer) on the raw Salesforce dataset and BigQuery Job User (roles/bigquery.jobUser) on buildProjectId. Unlike SAP ERP, Salesforce doesn't require a metadata dictionary table such as DD03L; the build tool inspects raw table schemas directly through the BigQuery API.
    • CLI deploy principal (uv run cortex-deploy): Dataform Editor (roles/dataform.editor) on the Dataform repository project, and BigQuery Data Editor (roles/bigquery.dataEditor) on the target projects or datasets (to inspect or create target datasets with --create-datasets).
    • Dataform execution service account: BigQuery Data Viewer (roles/bigquery.dataViewer) on the raw Salesforce dataset, BigQuery Data Editor (roles/bigquery.dataEditor) on the target foundation and data product datasets, and BigQuery Job User (roles/bigquery.jobUser) on the execution project.

Requirements for replicated Salesforce tables

Verify that your replicated Salesforce tables in BigQuery meet the following schema and behavioral requirements:

  1. Use standard Salesforce PascalCase API names for raw tables (for example, Account, OpportunityLineItem, Pricebook2, and CaseHistory) and preserve original PascalCase column names (such as Id, AccountId, SystemModstamp, and IsDeleted). By default, the cortex.sfdc.foundations.sfdc module normalizes PascalCase source table names into snake_case target tables and .js definitions (such as account, opportunity_line_item, pricebook2, and case_history, while preserving existing underscores on custom objects such as My_Custom_Object__c to my_custom_object__c) and keeps PascalCase column names; downstream data products expose curated snake_case columns. If a raw table uses a non-standard or prefixed physical name (for example, raw_Account), copy the full default table list from src/data_modules/cortex/sfdc/foundations/sfdc/table_settings.default.yaml into a custom table_settings.yaml file (wired with tableSettings) or inlineTableSettings, and update the target entry with source.tableName (the physical raw table name) and source.sfdcTableName (the canonical Salesforce SObject API name, for example, Account). On a foundation module, tableSettings and inlineTableSettings replace table_settings.default.yaml completely rather than merging with it; declaring only the renamed table removes all other SObjects and fails validation for enabled prebuilt Salesforce data products. The builder resolves annotations/<snake_name>.yaml and derives the default snake_case target table name from source.sfdcTableName unless you override target.tableName.
  2. Include the primary key column (Id by default, or custom key columns configured in source.keys) and at least one system timestamp column on every Change Data Capture (CDC) table (isCdc: true). During incremental MERGE execution, Cortex Framework selects the watermark column in the following priority order:

    • SystemModstamp (preferred; captures both user edits and automated system updates)
    • LastModifiedDate
    • CreatedDate (used for append-only history objects such as CaseHistory that lack SystemModstamp)

    Each incremental run applies a 10-minute lookback window (INTERVAL 10 MINUTE) against the maximum target watermark to capture late-arriving records without gaps.

  3. Replicate low-volume administrative reference objects (or custom objects that lack incremental watermark columns) as full snapshots (ingestionType: "full" in BigQuery Data Transfer Service). In the default Salesforce foundation configuration, CurrencyType, Organization, and RecordType set isCdc: false and rebuild completely during each pipeline run.

  4. Preserve the boolean IsDeleted column on deletable SObjects so soft-deleted records remain auditable. The foundation MERGE logic updates deleted rows in place and retains them with IsDeleted = TRUE (exposed as is_deleted = TRUE in source-aligned data products) to maintain historical referential integrity. Downstream consumption overview tables and child array rollups automatically exclude rows where is_deleted = TRUE.

  5. Replicate any Salesforce custom fields (*__c) that you want to expose in reporting. Only the Salesforce foundation builder (SfdcFoundationBuilder, used by cortex.sfdc.foundations.sfdc) detects raw *__c custom and managed-package columns at build time and propagates them into conformed foundation tables (onSchemaChange: "EXTEND" on CDC tables). Prebuilt Salesforce data products (both source-aligned and consumption) define explicit column projections in their .js definitions for standard canonical columns only so schemas remain deterministic. To expose *__c fields in analytics, query the conformed foundation tables from a custom or extended data product in your custom namespace.

Configure the Salesforce foundation module

In config/config.yaml, register the cortex namespace, declare your raw and target datasets under data.datasets, add the cortex.sfdc.foundations.sfdc foundation module, and bind downstream Salesforce data products in dependencyBindings:

buildEnvironment:
  buildProjectId: BUILD_PROJECT_ID

data:
  bigQueryLocation: US
  namespaces:
    - name: cortex

  # Register raw inbound and target conformed/product datasets.
  datasets:
    - id: sfdc_raw
      projectId: SOURCE_PROJECT_ID
      datasetId: cortex_sfdc_raw
    - id: sfdc_foundation
      projectId: TARGET_PROJECT_ID
      datasetId: cortex7_sfdc_data_foundation
    - id: sfdc_products
      projectId: TARGET_PROJECT_ID
      datasetId: cortex7_sfdc_products

  modules:
    foundations:
      # Salesforce foundation module instance.
      - moduleId: sfdc
        modulePath: cortex.sfdc.foundations.sfdc
        dataSourceId: sfdc_raw
        dataTargetId: sfdc_foundation
        enabled: true
        external: false
        # Optional custom table settings file (relative to 'config/') or
        # inlineTableSettings (mutually exclusive); replaces
        # table_settings.default.yaml completely:
        # tableSettings: "cortex/sfdc/foundations/sfdc/table_settings.yaml"
    products:
      # Source-aligned Salesforce data products bind to sfdcModule.
      - moduleId: sfdc_accounts
        modulePath: cortex.sfdc.products.accounts
        dataTargetId: sfdc_products
        dependencyBindings:
          sfdcModule: sfdc
        enabled: true
        syncToKc: true
      # Consumption data products bind to enabled source-aligned moduleIds
      # (ensure each bound upstream moduleId is also declared in products).
      # - moduleId: sfdc_opportunity_pipeline
      #   modulePath: cortex.sfdc.products.opportunity_pipeline
      #   dataTargetId: sfdc_products
      #   dependencyBindings:
      #     sfdcAccounts: sfdc_accounts
      #     sfdcConfiguration: sfdc_configuration
      #     sfdcCurrencyAndConversion: sfdc_currency_and_conversion
      #     sfdcOpportunities: sfdc_opportunities
      #     sfdcProductsAndPricing: sfdc_products_and_pricing

Replace the following:

  • BUILD_PROJECT_ID: the Google Cloud project ID that runs build and validation jobs, for example: my-build-project.
  • SOURCE_PROJECT_ID: the Google Cloud project ID that hosts your replicated raw Salesforce dataset, for example: my-source-project.
  • TARGET_PROJECT_ID: the Google Cloud project ID where Cortex Framework creates foundation and data product tables, for example: my-target-project.

If you ingest data from multiple Salesforce organizations, declare separate raw and foundation dataset entries and register a distinct foundation moduleId (for example, sfdc_amer and sfdc_emea) for each organization. Note that soft-delete state is preserved in place using the IsDeleted column (the legacy v6 removeIsDeleted key isn't supported).

After you configure config/config.yaml (including the deployment target repository settings), compile and deploy your pipelines:

export CORTEX_CONFIG_FILE=config/config.yaml
uv run cortex-build-and-deploy --config $CORTEX_CONFIG_FILE

Then run the generated Dataform actions as described in Post-deployment steps.

What's next