Salesforce
The Salesforce connector lets you perform insert, delete, update, and read operations on Salesforce data.
Supported versions
The connector requires the Web Services API. The Web Services API is supported natively by Salesforce Enterprise, Unlimited, and Developer editions. The Web Services API may be enabled on Professional Edition at an additional cost by contacting Salesforce. The connector defaults to version 56.0 of the Salesforce API.
Before you begin
Before using the Salesforce connector, do the following tasks:
- In your Google Cloud project:
- Ensure that network connectivity is set up. For information about network patterns, see Network connectivity.
- Grant the roles/connectors.admin IAM role to the user configuring the connector.
- Grant the following IAM roles to the service account that you want to use for the connector:
roles/secretmanager.viewer
roles/secretmanager.secretAccessor
A service account is a special type of Google account intended to represent a non-human user that needs to authenticate and be authorized to access data in Google APIs. If you don't have a service account, you must create a service account. For more information, see Creating a service account.
- Enable the following services:
secretmanager.googleapis.com
(Secret Manager API)connectors.googleapis.com
(Connectors API)
To understand how to enable services, see Enabling services.
If these services or permissions have not been enabled for your project previously, you are prompted to enable them when configuring the connector.
Configure the connector
Configuring the connector requires you to create a connection to your data source (backend system). A connection is specific to a data source. It means that if you have many data sources, you must create a separate connection for each data source. To create a connection, do the following steps:
- In the Cloud console, go to the Integration Connectors > Connections page and then select or create a Google Cloud project.
- Click + CREATE NEW to open the Create Connection page.
- In the Location section, choose the location for the connection.
- Region: Select a location from the drop-down list.
For the list of all the supported regions, see Locations.
- Click NEXT.
- Region: Select a location from the drop-down list.
- In the Connection Details section, complete the following:
- Connector: Select Salesforce from the drop down list of available Connectors.
- Connector version: Select the Connector version from the drop down list of available versions.
- In the Connection Name field, enter a name for the Connection instance.
Connection names must meet the following criteria:
- Connection names can use letters, numbers, or hyphens.
- Letters must be lower-case.
- Connection names must begin with a letter and end with a letter or number.
- Connection names cannot exceed 49 characters.
- Optionally, enter a Description for the connection instance.
- Optionally, enable Cloud logging,
and then select a log level. By default, the log level is set to
Error
. - Service Account: Select a service account that has the required roles.
- Optionally, configure the Connection node settings:
- Minimum number of nodes: Enter the minimum number of connection nodes.
- Maximum number of nodes: Enter the maximum number of connection nodes.
A node is a unit (or replica) of a connection that processes transactions. More nodes are required to process more transactions for a connection and conversely, fewer nodes are required to process fewer transactions. To understand how the nodes affect your connector pricing, see Pricing for connection nodes. If you don't enter any values, by default the minimum nodes are set to 2 (for better availability) and the maximum nodes are set to 50.
- Use proxy: Select this checkbox to configure a proxy server for the connection and configure the following values:
-
Proxy Auth Scheme: Select the authentication type to authenticate with the proxy server. The following authentication types are supported:
- Basic: Basic HTTP authentication.
- Digest: Digest HTTP authentication.
- Proxy User: A user name to be used to authenticate with the proxy server.
- Proxy Password: The Secret manager secret of the user's password.
-
Proxy SSL Type: The SSL type to use when connecting to the proxy server. The following authentication types are supported:
- Auto: Default setting. If the URL is an HTTPS URL, then the Tunnel option is used. If the URL is an HTTP URL, then the NEVER option is used.
- Always: The connection is always SSL enabled.
- Never: The connection is not SSL enabled.
- Tunnel: The connection is through a tunneling proxy. The proxy server opens a connection to the remote host and traffic flows back and forth through the proxy.
- In the Proxy Server section, enter details of the proxy server.
- Click + Add destination.
- Select a Destination Type.
- Host address: Specify the hostname or IP address of the destination.
If you want to establish a private connection to your backend system, do the following:
- Create a PSC service attachment.
- Create an endpoint attachment and then enter the details of the endpoint attachment in the Host address field.
- Host address: Specify the hostname or IP address of the destination.
- Optionally, click + ADD LABEL to add a label to the Connection in the form of a key/value pair.
- Click NEXT.
- Destination Type: Select a Destination Type.
- Select Host address from the list to specify the hostname or IP address of the destination.
- If you want to establish a private connection to your backend systems, select Endpoint attachment from the list, and then select the required endpoint attachment from the Endpoint Attachment list.
If you want to establish a public connection to your backend systems with additional security, you can consider configuring static outbound IP addresses for your connections, and then configure your firewall rules to allowlist only the specific static IP addresses.
To enter additional destinations, click +ADD DESTINATION.
- Click NEXT.
- Select an Authentication type and enter the relevant details.
The following authentication types are supported by the Salesforce connection:
- OAUTH2_JWT_BEARER
- Username and password
- Click NEXT.
To understand how to configure these authentication types, see Configure authentication.
Configure authentication
Enter the details based on the authentication you want to use.
-
OAUTH2_JWT_BEARER
- Connected App Consumer Key: The consumer key provided by Salesforce for the connected app you created.
- Username: The username associated with the connected app you created.
- Private Key: Secret Manager Secret containing the contents of the private key file. The private key should match the public key/certificate provided to Salesforce.
-
Username and password
- Username: The Salesforce username to use for the connection.
- Password: Secret Manager Secret containing the password associated with the Salesforce username.
- Security Token: Secret Manager Secret containing case-sensitive alphanumeric code provided by Salesforce for the user.
Connection configuration samples
This section lists the sample values for the various fields that you configure when creating the connection.
Username and password connection type
Field name | Details |
---|---|
Location | us-central1 |
Connector | salesforce |
Connector version | 1 |
Connection Name | gcp-salesforce-conn |
Enable Cloud Logging | Yes |
Log Level | Error |
Service Account | [email protected] |
Verbosity Level | 5 |
Minimum number of nodes | 2 |
Maximum number of nodes | 50 |
Destination Type | Host address |
Host 1 | https://login.salesforce.com. |
Username | USERNAME |
Password | PASSWORD |
Secret version | 1 |
Security Token | Token/alphanumeric code provided by Salesforce for the user. |
Secret version | 1 |
Entities, operations, and actions
All the Integration Connectors provide a layer of abstraction for the objects of the connected application. You can access an application's objects only through this abstraction. The abstraction is exposed to you as entities, operations, and actions.
- Entity: An entity can be thought of as an object, or a collection of properties, in the
connected application or service. The definition of an entity differs from a connector to a
connector. For example, in a database connector, tables are the entities, in a
file server connector, folders are the entities, and in a messaging system connector,
queues are the entities.
However, it is possible that a connector doesn't support or have any entities, in which case the
Entities
list will be empty. - Operation: An operation is the activity that you can perform on an entity. You can perform
any of the following operations on an entity:
Selecting an entity from the available list, generates a list of operations available for the entity. For a detailed description of the operations, see the Connectors task's entity operations. However, if a connector doesn't support any of the entity operations, such unsupported operations aren't listed in the
Operations
list. - Action: An action is a first class function that is made available to the integration
through the connector interface. An action lets you make changes to an entity or entities, and
vary from connector to connector. Normally, an action will have some input parameters, and an output
parameter. However, it is possible
that a connector doesn't support any action, in which case the
Actions
list will be empty.
System limitations
The Salesforce connector can process a maximum of 28 transactions per second, per node, and throttles any transactions beyond this limit. By default, Integration Connectors allocates 2 nodes (for better availability) for a connection.
For information on the limits applicable to Integration Connectors, see Limits.
Actions
This connector lets you perform insert, delete, update, and read operations on Salesforce data. To execute custom SQL queries, the connector provides the Execute custom query action.
To create a custom query, follow these steps:
- Follow the detailed instructions to add a connectors task.
- When you configure the connector task, in the type of action you want to perform, select Actions.
- In the Action list, select Execute custom query, and then click Done.
- Expand the Task input section, and then do the following:
- In the Timeout after field, enter the number of seconds to wait till the query executes.
Default value:
180
seconds. - In the Maximum number of rows field, enter the maximum number of rows to be returned from the database.
Default value:
25
. - To update the custom query, click Edit Custom Script. The Script editor dialog opens.
- In the Script editor dialog, enter the SQL query and click Save.
You can use a question mark (?) in a SQL statement to represent a single parameter that must be specified in the query parameters list. For example, the following SQL query selects all rows from the
Employees
table that matches the values specified for theLastName
column:SELECT * FROM Employees where LastName=?
- If you've used question marks in your SQL query, you must add the parameter by clicking + Add Parameter Name for each question mark. While executing the integration, these parameters replace the question marks (?) in the SQL query sequentially. For example, if you have added three question marks (?), then you must add three parameters in order of sequence.
To add query parameters, do the following:
- From the Type list, select the data type of the parameter.
- In the Value field, enter the value of the parameter.
- To add multiple parameters, click + Add Query Parameter.
- In the Timeout after field, enter the number of seconds to wait till the query executes.
The Salesforce connector doesn't support parameterized values for the OFFSET clause, and it can't be dynamically replaced using query parameters. However, query parameters are supported in the WHERE clause.
This section lists the actions supported by the Salesforce connector. To understand how to configure the actions, see Action examples.
CreateJobv2 action
Use this action to create a Job.
Input parameters of the CreateJobV2 action
Parameter Name | Data Type | Required | Description |
---|---|---|---|
ObjectName | String | Yes | The name of the object to be used for the job, such as Account, Campaign, Event, etc. |
Query | String | No | The query to be performed. |
Action | String | Yes | Type of action to use in the job. Valid values are 'insert', 'delete', 'update', 'upsert' or 'query'. |
ExternalIdColumn | String | No | The external ID field in the object being updated. This is required for upsert operations. The field values must also exist in CSV job data. |
ColumnDelimiter | String | No | The column delimiter used for CSV job data. The default value is COMMA. Valid values are 'BACKQUOTE','CARET','COMMA', 'PIPE', 'SEMICOLON', and 'TAB'. |
LineEnding | String | No | The line ending used for CSV job data, marking the end of a data row. The default is LF. Valid values are 'LF' and 'CRLF'. |
MultiPartRequest | Boolean | No | Enable this feature only if the data in the CSV file does not exceed 20,000 characters. You must also specify the path of your CSV file. |
CSVFilePath | String | No | Specifies the path of your CSV File. |
For example on how to configure the CreateJobV2
action,
see Examples.
UploadJobDataV2 action
Use this action to upload a Job file in CSV format to Salesforce.
Input parameters of the UploadJobDataV2 action
Parameter Name | Data Type | Required | Description |
---|---|---|---|
ContentUrl | String | No | The URL to use for 'Upload Job Data' requests for this job. Only valid if the job is in Open state. |
CSVFilePath | String | No | Specify the path of your CSV File. |
Content | String | Yes | The CSV file content as an InputStream. To be provided only if CSVFilePath is empty. |
For example on how to configure the UploadJobDataV2
action,
see Examples.
CreateBatch action
This action creates a Salesforce batch.
Input parameters of the CreateBatch action
Parameter Name | Data Type | Required | Description |
---|---|---|---|
JobId | String | True | Id of the job the batch is being added to. |
Aggregate | String | True | The aggregate of objects being added. Specifies the query to use if performing a batch query. |
ContentType | String | True | The content type for the job. Following are the valid values: CSV, XML, ZIP_CSV, and ZIP_XML. Set the value to CSV if you perform a batch query. The default value is XML. |
Output parameters of the CreateBatch action
For example on how to configure the CreateBatch
action,
see Examples.
CreateJob action
This action adds a Salesforce object entry.
Input parameters of the CreateJob action
Parameter Name | Data Type | Required | Description |
---|---|---|---|
ObjectName | String | True | Name of the object to be used for the job |
Action | String | True | Type of action to use in the job. |
Output parameters of the CreateJob action
For example on how to configure the CreateJob
action,
see Examples.
GetBatch action
This action gets information about a Salesforce batch.
Input parameters of the GetBatch action
Parameter Name | Data Type | Required | Description |
---|---|---|---|
JobId | String | True | Id of the job the batch is associated with. |
BatchId | String | True | Id of the batch being retrieved. |
Output parameters of the GetBatch action
For example on how to configure the GetBatch
action,
see Examples.
GetJob action
This action gets information about a Salesforce job.
Input parameters of the GetJob action
Parameter Name | Data Type | Required | Description |
---|---|---|---|
JobId | String | True | Id of the job being retrieved. |
Output parameters of the GetJob action
For example on how to configure the GetJob
action,
see Examples.
UploadAttachment action
This action uploads an attachment and associates it with an entity in Salesforce.
Input parameters of the UploadAttachment action
Parameter Name | Data Type | Required | Description |
---|---|---|---|
ObjectId | String | True | The Id of the object to associate the uploaded document with. |
FileName | String | True | The name for the attachment. |
Base64Data | String | True | The string of data to be used as content for the file. |
Output parameters of the UploadAttachment action
For example on how to configure the UploadAttachment
action,
see Examples.
GetBatchResults action
This action gets the results of a Salesforce batch.
Input parameters of the GetBatchResults action
Parameter Name | Data Type | Required | Description |
---|---|---|---|
JobId | String | True | Id of the job the batch is associated with. |
BatchId | String | True | Id of the batch being retrieved. |
ContentType | String | True | The content type for the job. |
Output parameters of the GetBatchResults action
For example on how to configure the GetBatchResults
action,
see Examples.
Action examples
Example - CreateJobV2
This example creates a Job.
- In the
Configure connector task
dialog, clickActions
. - Select the
CreateJobV2
action, and then click Done. - In the Task Input section of the Connectors task, click
connectorInputPayload
and then you must enter a value similar to the following in theDefault Value
field:{ "ObjectName": "Contact", "Action": "insert" }
If the action is successful, the
CREATEJOBV2
task's connectorOutputPayload
response
parameter will have a value similar to the following:
[{ "ID": "750dM000005HjdnQAC", "State": "Open", "JobType": null, "ContentUrl": "services/data/v43.0/jobs/ingest/750dM000005HjdnQAC/batches", "ContentType": "CSV", "CreatedDate": "2024-08-07T09:16:16.000+0000", "CreatedById": "005dM0000061WSFQA2", "ConcurrencyMode": "Parallel", "SystemModStamp": "2024-08-07T09:16:16.000+0000" }]
Example - UploadJobDataV2
This example uploads a Job file to Salesforce.
- In the
Configure connector task
dialog, clickActions
. - Select the
UploadJobDataV2
action, and then click Done. - In the Task Input section of the Connectors task, click
connectorInputPayload
and then enter a value similar to the following in theDefault Value
field:{ "Content": "FirstName,LastName,Email,MobilePhone,External_Id__c\\nGinelle,Merioth,[email protected],851-555-8435,4d13cac0-2c11-48e9-891d-49ee9508a6c7\\nDalli,Tumilson,[email protected],881-555-6742,38bcb24b-247f-498b-9502-c98995a1e04b\\nRobbin,Purveys,[email protected],732-555-6909,35d96c7a-3856-4809-8c49-35ddb9fa7dd9\\nLothaire,Ivanchenkov,[email protected],144-555-1959,75f63f26-6f4a-406f-a9f4-807f4a8a7b51", "ContentUrl": "services/data/v43.0/jobs/ingest/750dM000005HjdnQAC/batches" }
If the action is successful, the
UploadJobDataV2
task's connectorOutputPayload
response
parameter will have a value similar to the following:
[{ "Uploaded": "true" }]
Example - CreateBatch
- In the
Configure connector task
dialog, clickActions
. - Select the
CreateBatch
action, and then click Done. - In the Data Mapping section
Open Data Mapping Editor
and then enter a value similar to the following in theInput
field:{ "JobId": "750dL000007EipxQAC", "Aggregate": "
\n \nWalter \nWhite \n\n \n", "ContentType": "XML" }Rob \nBrown \n
If the action is successful, the
CreateBatch
task's connectorOutputPayload
response
parameter will have a value similar to the following:
[{ "ID": "751dL000003ziC5QAI", "JobID": "750dL000007EipxQAC", "ApexProcessingTime": "0", "ApiActiveProcessingTime": "0", "CreatedDate": "2024-09-03T04:48:53.000Z", "NumberRecordsFailed": "0", "NumberRecordsProcessed": "0", "State": "Queued", "StateMessage": null, "SystemModstamp": "2024-09-03T04:48:53.000Z", "TotalProcessingTime": "0" }]
Example - CreateJob
- In the
Configure connector task
dialog, clickActions
. - Select the
CreateJob
action, and then click Done. - In the Data Mapping section
Open Data Mapping Editor
and then enter a value similar to the following in theInput
field:{ "ObjectName": "Campaign", "Action": "insert" }
If the action is successful, the
CreateJob
task's connectorOutputPayload
response
parameter will have a value similar to the following:
[{ "ID": "750dL000007GgD7QAK", "JobID": "750dL000007GgD7QAK", "ObjectName": "Campaign", "Operation": "insert", "ApiVersion": "56.0", "ApexProcessingTime": "0", "ApiActiveProcessingTime": "0", "AssignmentRuleId": null, "ConcurrencyMode": "Parallel", "ContentType": "XML", "CreatedById": "005dL000007CalFQAS", "CreatedDate": "2024-09-03T05:31:41.000Z", "ExternalIdFieldName": null, "NumberBatchesCompleted": "0", "NumberBatchesQueued": "0", "NumberBatchesFailed": "0", "NumberBatchesInProgress": "0", "NumberBatchesTotal": "0", "NumberRecordsFailed": "0", "NumberRecordsProcessed": "0", "NumberRetries": "0", "State": "Open", "SystemModStamp": "2024-09-03T05:31:41.000Z", "TotalProcessingTime": "0" }]
Example - GetBatch
- In the
Configure connector task
dialog, clickActions
. - Select the
GetBatch
action, and then click Done. - In the Data Mapping section
Open Data Mapping Editor
and then enter a value similar to the following in theInput
field:{ "BatchId": "751dL000003yKlJQAU", "JobId": "750dL000007EipxQAC" }
If the action is successful, the
GetBatch
task's connectorOutputPayload
response
parameter will have a value similar to the following:
[{ "ID": "751dL000003yKlJQAU", "JobID": "750dL000007EipxQAC", "ApexProcessingTime": "0", "ApiActiveProcessingTime": "0", "CreatedDate": "2024-09-02T11:44:15.000Z", "NumberRecordsFailed": "0", "NumberRecordsProcessed": "0", "State": "Failed", "StateMessage": "InvalidBatch : Failed to parse XML. Unexpected XML element 'sObject' found at START_TAG seen ... @1:9 it should be 'sObjects'", "SystemModstamp": "2024-09-02T11:44:15.000Z", "TotalProcessingTime": "0" }]
Example - GetJob
- In the
Configure connector task
dialog, clickActions
. - Select the
GetJob
action, and then click Done. - In the Data Mapping section
Open Data Mapping Editor
and then enter a value similar to the following in theInput
field:{ "JobId": "750dL000007EipxQAC" }
If the action is successful, the
GetJob
task's connectorOutputPayload
response
parameter will have a value similar to the following:
[{ "ID": "750dL000007EipxQAC", "JobID": "750dL000007EipxQAC", "ObjectName": "Campaign", "Operation": "insert", "ApiVersion": "56.0", "ApexProcessingTime": "0", "ApiActiveProcessingTime": "0", "AssignmentRuleId": null, "ConcurrencyMode": "Parallel", "ContentType": "XML", "CreatedById": "005dL000007CalFQAS", "CreatedDate": "2024-09-02T11:17:42.000Z", "ExternalIdFieldName": null, "NumberBatchesCompleted": "0", "NumberBatchesQueued": "0", "NumberBatchesFailed": "2", "NumberBatchesInProgress": "0", "NumberBatchesTotal": "2", "NumberRecordsFailed": "0", "NumberRecordsProcessed": "0", "NumberRetries": "0", "State": "Open", "SystemModStamp": "2024-09-02T11:17:42.000Z", "TotalProcessingTime": "0" }]
Example - UploadAttachment
- In the
Configure connector task
dialog, clickActions
. - Select the
UploadAttachment
action, and then click Done. - In the Data Mapping section
Open Data Mapping Editor
and then enter a value similar to the following in theInput
field:{ "ObjectId": "001dL00000SC6j7QAD", "FileName": "My files/salesforce/con.csv", "Base64Data": "Y29ubmVjdG9ycyBpcyBiYWNr" }
If the action is successful, the
UploadAttachment
task's connectorOutputPayload
response
parameter will have a value similar to the following:
[{ "Id": "00PdL000000EJUDUA4" }]
Example - GetBatchResults
- In the
Configure connector task
dialog, clickActions
. - Select the
GetBatchResults
action, and then click Done. - In the Data Mapping section
Open Data Mapping Editor
and then enter a value similar to the following in theInput
field:{ "BatchId": "751dL000004D17FQAS", "JobId": "750dL000007XKUhQAO", "ContentType": "XML" }
If the action is successful, the
GetBatchResults
task's connectorOutputPayload
response
parameter will have a value similar to the following:
[{ "ID": null, "Created": "false", "Success": "false", "Errors_Fields": "LastName", "Errors_Message": "Account: bad field names on insert/update call: FirstName, LastName", "Errors_StatusCode": "INVALID_FIELD_FOR_INSERT_UPDATE" }, { "ID": null, "Created": "false", "Success": "false", "Errors_Fields": "LastName", "Errors_Message": "Account: bad field names on insert/update call: FirstName, LastName", "Errors_StatusCode": "INVALID_FIELD_FOR_INSERT_UPDATE" }]
Entity operation examples
This section shows how to perform some of the entity operations in this connector.
Example - Create an attachment
- In the
Configure connector task
dialog, clickEntities
. - Select Attachment from the
Entity
list. - Select the
Create
operation, and then click Done. - In the Data mapper section of the Task click
OpenDataMapping
editor and then enter a value similar to the following in thefield:
{ "Name": "New Attachment", "Description": "New created attachment", "ParentId": "001dL00000SC6j7QAD", "Body": "Body" }
Running this example, returns a response similar to the following in the Connector task's
connectorOutputPayload
output variable:{ "Id": "00PdL000000EJKXUA4" }
Entity create attachment only creates an attachment with no content file in it. In order to add a file we need to perform Upload Attachment action by giving a file context in the input.
Example - Update an attachment
- In the
Configure connector task
dialog, clickEntities
. - Select Attachment from the
Entity
list. - Select the
Update
operation, and then click Done. - Set the entity ID to Update an Attachment. To set the entity ID, in
the Data mapper section of the Tasks, click EntityID and
then enter
00PdL000000EJKXUA4
in the given field. - In the Data mapper section of the Task click
OpenDataMapping
editor and then enter a value similar to the following in thefield:
{ "Name": "New Attachment", "Description": "New updated attachment", "Body": "Body" }
Running this example, returns a response similar to the following in the Connector task's
connectorOutputPayload
output variable:{ "Id": "00PdL000000EJKXUA4" }
Entity update attachment only updates the attachment name or description. In order to add a file we need to perform Upload Attachment action by giving a file context in the input.
Alternately, instead of specifying the entityId, you can also set the
filterClause to 00PdL000000EJKXUA4
.
Use terraform to create connections
You can use the Terraform resource to create a new connection.To learn how to apply or remove a Terraform configuration, see Basic Terraform commands.
To view a sample terraform template for connection creation, see sample template.
When creating this connection by using Terraform, you must set the following variables in your Terraform configuration file:
Parameter name | Data type | Required | Description |
---|---|---|---|
proxy_enabled | BOOLEAN | False | Select this checkbox to configure a proxy server for the connection. |
proxy_auth_scheme | ENUM | False | The authentication type to use to authenticate to the ProxyServer proxy. Supported values are: BASIC, DIGEST, NONE |
proxy_user | STRING | False | A user name to be used to authenticate to the ProxyServer proxy. |
proxy_password | SECRET | False | A password to be used to authenticate to the ProxyServer proxy. |
proxy_ssltype | ENUM | False | The SSL type to use when connecting to the ProxyServer proxy. Supported values are: AUTO, ALWAYS, NEVER, TUNNEL |
Use the Salesforce connection in an integration
After you create the connection, it becomes available in both Apigee Integration and Application Integration. You can use the connection in an integration through the Connectors task.
- To understand how to create and use the Connectors task in Apigee Integration, see Connectors task.
- To understand how to create and use the Connectors task in Application Integration, see Connectors task.
Get help from the Google Cloud community
You can post your questions and discuss this connector in the Google Cloud community at Cloud Forums.What's next
- Understand how to suspend and resume a connection.
- Understand how to monitor connector usage.
- Understand how to view connector logs.