Salesforce Update Sink
Provided by: "Apache Software Foundation"
Support Level for this Kamelet is: "Stable"
Changes fields of an existing Salesforce record, such as the phone number of a contact, for each message; the message names the record and the new values.
Use it to keep Salesforce records in step with another system, for example to update the address of an account when it changes in the ERP. To create records use salesforce-create-sink, and to create or update many records matched by an external ID, salesforce-composite-upsert-sink.
Input: the body is JSON text with three fields: sObjectName, the API name of the kind of record (such as Contact); sObjectId, the ID of the record; and payload, an object with the fields to change and their new values. For example {"sObjectName": "Contact", "sObjectId": "003XXXXXXXXXXXXXXX", "payload": {"Phone": "+45 1234 5678"}}. The fields that are not in payload keep their values.
Output: when it is used inside a route, the body afterwards is the payload as JSON text.
Good to know: a message without sObjectName or sObjectId, for a record that does not exist, or with a change that Salesforce refuses, fails. The message decides which record is changed, so place this sink only after a source you trust. Headers that start with CamelSalesforce are removed from the message first, so they cannot change what the Kamelet does.
Configuration Options
The following table summarizes the configuration options available for the salesforce-update-sink Kamelet:
| Property | Name | Description | Type | Default | Example |
|---|---|---|---|---|---|
Consumer Key | Required The consumer key of the connected app that the Kamelet logs in through. In Salesforce Setup, open App Manager, choose View on the app, then Manage Consumer Details. | string | |||
Consumer Secret | Required The consumer secret of the same connected app, shown next to the consumer key under Manage Consumer Details. | string | |||
Authentication Type | How the Kamelet logs in. Enum values: * USERNAME_PASSWORD * CLIENT_CREDENTIALS * REFRESH_TOKEN * JWT | string | USERNAME_PASSWORD | ||
Instance URL | The address of your org, such as | string | https://myinstance.my.salesforce.com | ||
JWT Audience | The audience of the JWT that the Kamelet signs to log in: | string | https://login.salesforce.com | ||
Keystore | A reference to a bean of type | string | #bean:myKeystore | ||
Login URL | The address the Kamelet logs in to. Keep the default for a production org, use | string | https://test.salesforce.com | ||
Password | The password of | string | |||
Refresh Token | A refresh token of the connected app for the user to act as, obtained once through an OAuth login in a browser with the | string | |||
Username | The user name of the Salesforce user to log in as, which looks like an email address. Used by the | string |
Dependencies
At runtime, the salesforce-update-sink Kamelet relies upon the presence of the following dependencies:
-
camel:jsonpath
-
camel:jackson3
-
camel:salesforce
-
camel:kamelet
Camel JBang usage
Prerequisites
-
You’ve installed JBang.
-
You have executed the following command:
jbang app install camel@apache/camel Supposing you have a file named route.yaml with this content:
- route:
from:
uri: "kamelet:timer-source"
parameters:
period: 10000
message: 'test'
steps:
- to:
uri: "kamelet:salesforce-update-sink" You can now run it directly through the following command
camel run route.yaml Salesforce Update Sink Kamelet Description
Salesforce CRM Integration
This Kamelet integrates with Salesforce CRM to update existing records. It provides record modification through Salesforce’s REST API.
Record Updates
Each message names the record to update and the new values, as JSON text:
{
"sObjectName": "Contact",
"sObjectId": "003XXXXXXXXXXXXXXX",
"payload": {
"Phone": "+45 1234 5678"
}
} -
sObjectName: the API name of the kind of record -
sObjectId: the Salesforce ID of the record -
payload: the fields to change, by their API names, with their new values
Field-Level Updates
Only the fields in payload are changed; the other fields of the record keep their values.
Validation and Workflow
Updated records are subject to Salesforce’s validation rules, workflow rules, and triggers. A change that Salesforce refuses fails the message.
API Authentication
The Kamelet logs in through a connected app of your org. Create one in Salesforce Setup, under App Manager, with OAuth enabled, and copy its consumer key and secret into clientId and clientSecret. authenticationType chooses how the Kamelet logs in, and which other options it needs.