$120 tested Claude codes · real before/after data · Full tier $15 one-timebuy --sheet=15 →
$Free 40-page Claude guide — setup, 120 prompt codes, MCP servers, AI agents. download --free →
clskills.sh — terminal v2.4 — 2,347 skills indexed● online
[CL]Skills_
SalesforceadvancedNew

Salesforce Platform Events

Share

Implement event-driven architecture with Platform Events and Change Data Capture

Works with OpenClaude

You are a Salesforce architect specializing in event-driven architecture. The user wants to implement real-time event publishing and consumption using Platform Events and Change Data Capture (CDC).

What to check first

  • Verify org has Platform Events and CDC licenses enabled: Check Setup → Feature Licenses
  • Run sfdx force:org:display to confirm org type and API version support (v45.0+ required for Platform Events)
  • Confirm user has "Manage Platform Events" and "Manage Change Data Capture" permissions in Setup → Users → Permission Sets

Steps

  1. Create a Platform Event object in Setup → Platform Events → New, define fields (add Currency__c, Status__c fields), set API name Order_Event__e
  2. Create a Pub/Sub API client using @salesforce/core or REST API to authenticate and establish persistent connection
  3. Implement a publish method using EventBus.publish() in Apex or REST endpoint /services/data/vXX.0/sobjects/Order_Event__e
  4. Enable Change Data Capture for target objects (Setup → Change Data Capture) and select Account, Opportunity objects to track
  5. Create a trigger or async handler subscribing to Platform Event Order_Event__e__e using trigger on Order_Event__e (after insert)
  6. Implement consumer logic that deserializes event payload and processes changes (update related records, call external APIs, publish to message queues)
  7. Set up Flows or Process Builder as alternative low-code consumers to trigger actions on event receipt
  8. Deploy using sfdx force:source:deploy and monitor via Setup → Integrations → Event Manager dashboard

Code

// Platform Event Publisher (Apex)
public class OrderEventPublisher {
    public static void publishOrderEvent(String orderId, String status, Decimal amount) {
        Order_Event__e event = new Order_Event__e(
            Order_ID__c = orderId,
            Status__c = status,
            Currency__c = amount
        );
        
        List<Database.SaveResult> results = EventBus.publish(
            new List<SObject>{ event }
        );
        
        for (Database.SaveResult result : results) {
            if (!result.isSuccess()) {
                for (Database.Error error : result.getErrors()) {
                    System.debug('Error: ' + error.getStatusCode() + ' - ' + error.getMessage());
                }
            }
        }
    }
}

// Platform Event Subscriber (Apex Trigger)
trigger OrderEventSubscriber on Order_Event__e (after insert) {
    List<Order> ordersToUpdate = new List<Order>();
    Map<String, String> eventMap = new Map<String, String>();
    
    for (Order_Event__e event : Trigger.new) {
        eventMap.put(event.Order_ID__c, event.Status__c);
    }
    
    for

Note: this example was truncated in the source. See the GitHub repo for the latest full version.

Common Pitfalls

  • Treating this skill as a one-shot solution — most workflows need iteration and verification
  • Skipping the verification steps — you don't know it worked until you measure
  • Applying this skill without understanding the underlying problem — read the related docs first

When NOT to Use This Skill

  • When a simpler manual approach would take less than 10 minutes
  • On critical production systems without testing in staging first
  • When you don't have permission or authorization to make these changes

How to Verify It Worked

  • Run the verification steps documented above
  • Compare the output against your expected baseline
  • Check logs for any warnings or errors — silent failures are the worst kind

Production Considerations

  • Test in staging before deploying to production
  • Have a rollback plan — every change should be reversible
  • Monitor the affected systems for at least 24 hours after the change

Quick Info

CategorySalesforce
Difficultyadvanced
Version1.0.0
AuthorClaude Skills Hub
salesforceeventscdc

Install command:

curl -o ~/.claude/skills/sf-platform-events.md https://clskills.in/skills/salesforce/sf-platform-events.md

Related Salesforce Skills

Other Claude Code skills in the same category — free to download.

Want a Salesforce skill personalized to YOUR project?

This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.