# Salesforce

## Prerequisites

The Omnata Salesforce Plugin connects to the core Salesforce CRM APIs, aka Sales and Service Cloud, and does not require any add-on products on the Salesforce side to operate. It also supports industry clouds, such as Health Cloud, that are built on the core CRM but have slightly different object schemas.

## Authentication methods

### OAuth (Client Credentials)

Omnata does not provide a centralized OAuth app for all customers to use. Instead, you will create a External Client App within your Salesforce instance.

{% hint style="info" %}
Currently, the Authorization Code flow is not available due to incompatibilities with Snowflake OAuth secrets.
{% endhint %}

#### Create the External Client App

1. Navigate to the App Manager and click "New External Client App"\
   ![](https://2119005510-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FedNbhp7XNeTdK7we4Ka5%2Fuploads%2Fcsmdjr5WflFNFDi4t840%2Fimage.png?alt=media\&token=ebd35d3c-754b-49e5-a6f4-2584d52e9a73)
2. Under Basic Information, use the following settings:
   1. Connected App Name: `Omnata Sync`
   2. Contact email: Chose any internal email\
      ![](https://2119005510-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FedNbhp7XNeTdK7we4Ka5%2Fuploads%2FIIPRusdCmYSH42AIANVU%2Fimage.png?alt=media\&token=1806ce45-2f47-4b9d-b5cf-5ebf8aff5411)
3. Under API (Enable OAuth Settings), check Enable OAuth\
   ![](https://2119005510-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FedNbhp7XNeTdK7we4Ka5%2Fuploads%2F3D7Hp9bCb56PJJ8h6Z43%2Fimage.png?alt=media\&token=4db1936d-ff33-4752-83f0-20224be3e065)
4. Under App Settings:
   1. Put `https://localhost` as the URL, this will not actually be used since we aren't using Authorization code flows
   2. Select OAuth Scopes:&#x20;
      * Manage user data via APIs (api)
      * Perform requests at any time (refresh\_token, offline\_access)\
        ![](https://2119005510-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FedNbhp7XNeTdK7we4Ka5%2Fuploads%2FKfjvfKdQ30dLBe6iFz6p%2Fimage.png?alt=media\&token=d94dff97-975f-4295-9df9-b3ae99c2985e)
5. Under Flow Enablement, check Enable Client Credentials Flow\
   ![](https://2119005510-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FedNbhp7XNeTdK7we4Ka5%2Fuploads%2FBYNyfnkChArWiSzZjrhT%2Fimage.png?alt=media\&token=ad1bb8da-2720-4906-94bd-6f7ba61bafbd)
6. Under Security, uncheck Require Proof Key for Code Exchange (PKCE) Extension for Supported Authorization Flows:\
   ![](https://2119005510-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FedNbhp7XNeTdK7we4Ka5%2Fuploads%2FpZuPLGLSDWNCImuMRNky%2Fimage.png?alt=media\&token=02e721e7-f96c-4758-b67b-fe7b8c4462f9)
7. Click Create:\
   ![](https://2119005510-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FedNbhp7XNeTdK7we4Ka5%2Fuploads%2FUaDz1sUlLfPBQTqs5wx0%2Fimage.png?alt=media\&token=f67e1854-c1c4-4fc7-a4df-694de1b4d4de)

{% hint style="info" %}
If you see this error in a Sandbox or Scratch org:\
\
**Failed to create an External Client App**\
**\[The Org Scoped External Client App must be in the format DeveloperOrganizationId:ExternalClientAppDeveloperName]**\
\
Then your environment may have been created during an awkward window in early 2026 where Salesforce had deprecated Connected Apps but not yet added support for External Client Apps.\
Orgs on Spring '26 or later should not experience this issue.
{% endhint %}

8. After the external client app has been created, click the Edit button under the policies tab:\
   ![](https://2119005510-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FedNbhp7XNeTdK7we4Ka5%2Fuploads%2Fz9vdpNaLPOLOQJnoJI04%2Fimage.png?alt=media\&token=1f607f52-2b5e-4a0d-929f-b27515883c9e)
9. Check Enable Client Credentials Flow and enter the username of the Salesforce user you wish to assume the privileges of from Snowflake. Also choose "Refresh token is valid until revoked" as the Refresh Token Policy:\
   ![](https://2119005510-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FedNbhp7XNeTdK7we4Ka5%2Fuploads%2F9Z3DxEiQFGvllRRkb1r1%2Fimage.png?alt=media\&token=73f322cd-a797-414c-955c-4d5d9d66f121)
10. Scroll down and click Save\
    ![](https://2119005510-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FedNbhp7XNeTdK7we4Ka5%2Fuploads%2FxxGGBi8kJ6oviAbPZiTb%2Fimage.png?alt=media\&token=8ec31d0a-18a0-4d38-9eb0-63ed167b601d)
11. Next, go to the Settings tab, expand OAuth Settings, and click the "Consumer Key and Secret" button:\
    ![](https://2119005510-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FedNbhp7XNeTdK7we4Ka5%2Fuploads%2FFQRpRQEki9aJYU8gpLMt%2Fimage.png?alt=media\&token=de41df4f-fa60-4993-86bd-9b4dab12bfa7)
12. You will be taken to Salesforce Classic in a new tab, and will be provided with the Consumer Key and Consumer Secret you need to provide in Omnata:\
    ![](https://2119005510-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FedNbhp7XNeTdK7we4Ka5%2Fuploads%2FmqX9UdSUcLUjk47XJv3U%2Fimage.png?alt=media\&token=6704814a-2aad-44f7-b3ce-8ebb119d1a70)
13. During the connection configuration process, you will also be asked for your Salesforce domain. You can find this under the "My Domain" section in Salesforce setup.

### Credentials

{% hint style="danger" %}
Salesforce deprecated Credential-based login in 2025 as described [here](https://help.salesforce.com/s/articleView?id=005132110\&type=1).

Omnata will continue to support existing Credential-based connections, but functionality will become increasingly limited and we strongly recommend migrating to OAuth.
{% endhint %}

Use your username, password, and security token to authenticate as a user.

If you don't know your security token, see the [Salesforce docs](https://help.salesforce.com/s/articleView?id=sf.user_security_token.htm\&type=5) for instructions on how to reset it.

## Inbound Syncs

### Supported Sync Strategies

* Full Refresh - Replace
* Full Refresh - Append
* Incremental - Append
* Incremental - Merge

### Supported Streams

The following objects are supported:

* Standard Objects - [See the list of Standard Salesforce Objects](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_list.htm).
* Custom Objects

There are some objects that appear in the global **describe()** results that are not valid for syncing, for various reasons:

* Any object ending in "ChangeEvent" is not allowed to be queried
* Certain objects don't support fetching via the query API, and some can only be fetched as a nested result in another object type
* If there is a particular object missing from the list which you expect to be able to sync, please get in touch at <support@omnata.com>

Each object is synced as a separate stream and appears as a separate table in Snowflake.

The available objects are determined by Salesforce access rules:

* The roles and permissions of the authenticated Salesforce user
* The Salesforce object must be accessible with the "queryable" property set to true.

## Outbound Syncs

### Sync Types

* Standard Objects
* Custom Objects
* Record Merge

### Sync Strategies

Standard and Custom Objects

* Upsert (requires an [External ID field](https://help.salesforce.com/s/articleView?id=000325076\&type=1) also marked as Unique)
* Update (requires the Salesforce 18 character system ID as an identifier)
* Mirror (requires an [External ID field](https://help.salesforce.com/s/articleView?id=000325076\&type=1) also marked as Unique)
* Create
* Delete

Record Merge

* Create - Calls the [merge() ](https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_merge.htm)operation to merge a source record (recordToMergeIds) into a target record (masterRecordId).
* Supports Lead, Contact, Account, Person Account, and Individual objects.

## Functions

### SOQL\_QUERY

Executes a SOQL query and returns the results.

Parameters:

* CONNECTION\_SLUG (VARCHAR): The slug of the connection to query
* QUERY (VARCHAR): The SOQL query
* USE\_BULK\_API (BOOLEAN): Set to true to use the Salesforce Bulk API, recommended if you expect a large number of results.

Examples:

```sql
select RECORD
from table(OMNATA_SALESFORCE_PLUGIN.UDFS.SOQL_QUERY(
                'my-salesforce-connection',
                'select Id, Name from Account',
                true));
```

### FETCH\_SOBJECTS

Fetches a list of all objects in the Org by using [global describe](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_describeGlobal.htm).

Parameters:

* CONNECTION\_SLUG (VARCHAR): The slug of the connection to query

Examples:

```sql
select *
from table(OMNATA_SALESFORCE_PLUGIN.UDFS.FETCH_SOBJECTS(
                'my-salesforce-connection'));
```

### FETCH\_SOBJECT\_FIELDS

Fetches a list of all field metadata for a given object in the Org.

Parameters:

* CONNECTION\_SLUG (VARCHAR): The slug of the connection to query
* SOBJECT\_NAME: Type of object to search for

Examples:

```sql
select *
from table(OMNATA_SALESFORCE_PLUGIN.UDFS.FETCH_SOBJECT_FIELDS(
                'my-salesforce-connection','Account'));
```

### FETCH\_PICKLIST\_VALUES

Fetches all picklist values for all fields.

Parameters:

* CONNECTION\_SLUG (VARCHAR): The slug of the connection to query

Examples:

```sql
select *
from table(OMNATA_SALESFORCE_PLUGIN.UDFS.FETCH_PICKLIST_VALUES(
                'my-salesforce-connection'));
```

### LIST\_STANDARD\_ACTIONS

Lists all available standard Salesforce actions.

{% hint style="info" %}
Some actions return errors in some environments when attempting to query the full details. If you see NULL values next to certain actions, check the Snowflake event table for warning messages to see the API error.
{% endhint %}

Parameters:

* CONNECTION\_SLUG (VARCHAR): The slug of the connection to query

Examples:

```sql
select *
from table(OMNATA_SALESFORCE_PLUGIN.UDFS.LIST_STANDARD_ACTIONS(
                'my-salesforce-connection'));
```

### INVOKE\_STANDARD\_ACTION

Invokes standard Salesforce actions. The list of available actions and required inputs can be retrieved via LIST\_STANDARD\_ACTIONS

Parameters:

* CONNECTION\_SLUG (VARCHAR): The slug of the connection to query
* ACTION\_NAME (VARCHAR): The name of the action
* INPUTS (OBJECT): Inputs to the action

This function returns a variant due to the variety of possible return values the different actions can return.

Examples:

```sql
select OMNATA_SALESFORCE_PLUGIN.UDFS.INVOKE_STANDARD_ACTION(
    'my-salesforce-connection',
    'emailSimple',
    {
        'emailAddresses':'james.weakley@omnata.com',
        'emailSubject': 'Hello via Standard Action',
        'emailBody': 'This email was sent via a Snowflake UDF!'
    });

select OMNATA_SALESFORCE_PLUGIN.UDFS.INVOKE_STANDARD_ACTION(
    'my-salesforce-connection',
    'findMatchingIndividuals',
    {
        'searchTerm':'john',
        'searchObject': 'Contact',
        'searchFields': 'All'
    });
```
