Salesforce Create Sink
Provided by: "Apache Software Foundation"
Support Level for this Kamelet is: "Stable"
Creates a new record, such as a contact, an account or a lead, in Salesforce for each message.
Use it to add to Salesforce what happens in other systems, for example a contact for each web form sent or a lead from a marketing tool. To change existing records use salesforce-update-sink, and to create or update many records at once, matched by an external ID, salesforce-composite-upsert-sink.
Input: the body is the fields of the new record as JSON text, with the API names of the fields, such as {"LastName": "Lovelace", "Email": "ada@example.com"}. It is sent to Salesforce as it is. The kind of record comes from sObjectName.
Output: when it is used inside a route, the body afterwards is the answer of Salesforce as JSON text, with the id of the new record, success and errors.
Good to know: a record that Salesforce refuses, for example because a required field is missing or a validation rule fails, fails the message. sObjectName must be set, or the Kamelet does not start. 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-create-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 | |||
Object Name | Required The API name of the kind of record to create, such as | string | Contact | ||
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-create-sink Kamelet relies upon the presence of the following dependencies:
-
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-create-sink" You can now run it directly through the following command
camel run route.yaml Salesforce Create Sink Kamelet Description
Salesforce CRM Integration
This Kamelet integrates with Salesforce CRM to create a new record for each message. It provides direct integration with Salesforce’s REST API for record creation operations.
Object Flexibility
The sObjectName option names the kind of record to create, by its API name. It supports any Salesforce object, including:
-
Standard objects (
Account,Contact,Lead, etc.) -
Custom objects specific to your organization, such as
Invoice__c -
Junction objects for many-to-many relationships
Field Mapping
The body is the fields of the new record as JSON text, with the API names of the fields. It is sent to Salesforce as it is, so turn the data of other systems into these names before this Kamelet.
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.
Data Validation
Salesforce’s validation rules, field requirements, and business logic apply to the new records. A record that Salesforce refuses fails the message.
Usage Example
- route:
from:
uri: "kamelet:timer-source"
parameters:
message: '{"LastName": "Lovelace", "Email": "ada@example.com"}'
contentType: application/json
repeatCount: 1
steps:
- to:
uri: "kamelet:salesforce-create-sink"
parameters:
sObjectName: Contact
clientId: "{{salesforce.clientId}}"
clientSecret: "{{salesforce.clientSecret}}"
userName: "{{salesforce.userName}}"
password: "{{salesforce.password}}"