Skip to main content

Salesforce Events

Salesforce event integrations subscribe to Change Data Capture (CDC) channels and trigger handler functions as records are created, updated, deleted, or restored in your Salesforce organization. Use them for real-time CRM synchronization, audit logging, and event-driven workflows that react to Salesforce record changes without polling.

Creating a Salesforce events service

  1. Click + Add Artifact in the canvas or click + next to Entry Points in the sidebar.

  2. In the Artifacts panel, select Salesforce under Event Integration.

  3. In the creation form, fill in the following fields:

    Salesforce Events creation form

    FieldDescription
    AuthCredentials for connecting to Salesforce. Accepts a record expression with username and password fields. Required. By default, the listener uses SOAP-based authentication. You can change the auth type after creation under Listener Configuration.

    Expand Advanced Configurations to set the listener name.

    FieldDescriptionDefault
    Listener NameIdentifier for the listener created with this service.salesforceListener
  4. Click Create.

  5. WSO2 Integrator opens the service in the Service Designer. The canvas shows the attached listener pill and the Event Handlers section with all four handlers pre-added.

    Service Designer showing the Salesforce Events service canvas

    The four event handlers — onCreate, onUpdate, onDelete, and onRestore — are added automatically when the service is created. Click any handler to open it in the flow diagram view and implement the logic.

Listener configuration

In the Service Designer, click the Configure icon in the header to open the Salesforce Event Integration Configuration panel. Select salesforceListener under Attached Listeners to configure the listener.

FieldDescriptionDefault
NameIdentifier for the listener.salesforceListener
AuthAuthentication credentials. SOAP-based authentication accepts a record expression with username and password fields. REST-based authentication is also supported. Select one of Bearer Token, Password Grant, Refresh Token, or Client Credentials.Required

Click Save Changes to apply updates.

Event handlers

When a Salesforce Events service is created, WSO2 Integrator adds all four handlers automatically. Click any handler in the Service Designer to open the flow diagram view and implement the processing logic.

Handler types

HandlerTriggered whenUse when
onCreateA record is created in SalesforceSyncing new records to downstream systems
onUpdateA record is updated in SalesforcePropagating field changes or triggering workflows
onDeleteA record is deleted in SalesforceCleaning up related data or auditing deletions
onRestoreA deleted record is restored (undeleted)Recovering soft-deleted records in downstream systems
note

You do not need to implement logic in all four handlers. Leave empty any handlers that are not relevant to your use case.

Event data type

Each handler receives a salesforce:EventData parameter with the change payload and metadata.

salesforce:EventData fields:

FieldTypeDescription
changedDatamap<json>Map of changed field names to their new values.
metadatasalesforce:ChangeEventMetadata?Metadata about the change event.

salesforce:ChangeEventMetadata fields:

FieldTypeDescription
entityNamestring?API name of the sObject that changed (e.g., "Account").
changeTypestring?Type of change: CREATE, UPDATE, DELETE, or UNDELETE.
changeOriginstring?Source of the change (e.g., "com/salesforce/api/rest/57.0").
transactionKeystring?Unique key identifying the transaction.
sequenceNumberint?Sequence number of the event within the transaction.
commitTimestampint?Unix timestamp in milliseconds when the change was committed.
commitNumberint?Transaction commit number.
commitUserstring?ID of the user who initiated the change.
recordIdstring?The record ID affected by the change.

Supported event channels

The CDC channel the service subscribes to is determined by the service path in Ballerina code.

Channel typeChannel patternUse case
Object-specific CDC/data/<ObjectName>ChangeEventReact to changes on a specific sObject (e.g., /data/AccountChangeEvent)
All CDC events/data/ChangeEventsCapture change events across all CDC-enabled objects

What's next