forcedotcom/sf-skills / plugins/builder/integration/skills/integration-connectivity-generate
integration-connectivity-generate
VerifiedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use integration-connectivity-connected-app-configure), Apex-only logic (use platform-apex-generate), data import/export (use platform-data-manage), or CDC channel-membership metadata such as PlatformEventChannel, PlatformEventChannelMember, or EnrichedField (use integration-eventing-cdc-configure).
assets/platform-events/event-subscriber-trigger.trigger
View on GitHub/**
* @description Platform Event Subscriber Trigger for {{EventName}}__e
*
* Use Case: React to published Platform Events
* - Process incoming events from other systems
* - Sync data based on events
* - Trigger downstream processes
*
* Key Concepts:
* - Platform Event triggers run in their own execution context
* - Events are processed in batches (up to 2000 for High Volume)
* - ReplayId enables resuming from failures
* - SetResumeCheckpoint ensures durability
*
* IMPORTANT:
* - Triggers on Platform Events only fire on AFTER INSERT
* - Events are immutable (cannot be updated or deleted)
* - Triggers run as Automated Process user
*
* @author {{Author}}
* @date {{Date}}
*/
trigger {{EventName}}Subscriber on {{EventName}}__e (after insert) {
// Track last processed replay ID for durability
String lastReplayId = '';
// Process each event
for ({{EventName}}__e event : Trigger.new) {
// Store replay ID for checkpoint
lastReplayId = event.ReplayId;
try {
// Log event receipt
System.debug(LoggingLevel.DEBUG,
'Processing event: ' + event.Correlation_Id__c +
' Operation: ' + event.Operation__c +
' ReplayId: ' + event.ReplayId);
// Route to handler based on operation
switch on event.Operation__c {
when 'CREATE' {
{{EventName}}Handler.handleCreate(event);
}
when 'UPDATE' {
{{EventName}}Handler.handleUpdate(event);
}
when 'DELETE' {
{{EventName}}Handler.handleDelete(event);
}
when else {
// Unknown operation - log and continue
System.debug(LoggingLevel.WARN,
'Unknown operation: ' + event.Operation__c +
' for event: ' + event.Correlation_Id__c);
}
}
} catch (Exception e) {
// Log error but continue processing other events
// Don't throw - that would cause retry of ALL events in batch
System.debug(LoggingLevel.ERROR,
'Error processing event ' + event.Correlation_Id__c + ': ' + e.getMessage());
System.debug(LoggingLevel.ERROR, 'Stack: ' + e.getStackTraceString());
// Consider: Create error log record for monitoring
// {{EventName}}ErrorLogger.logError(event, e);
}
}
// Set resume checkpoint for durability
// If trigger fails after this point, processing resumes from this ReplayId
if (String.isNotBlank(lastReplayId)) {
EventBus.TriggerContext.currentContext().setResumeCheckpoint(lastReplayId);
}
}
/*
* ============================================================================
* PLATFORM EVENT TRIGGER BEST PRACTICES
* ============================================================================
*
* 1. ALWAYS set resume checkpoint
* - Call setResumeCheckpoint() with the last processed ReplayId
* - Ensures events aren't lost if trigger fails mid-batch
*
* 2. DON'T throw exceptions
* - Unhandled exceptions cause entire batch to retry
* - Catch errors per-event and log them
* - Continue processing remaining events
*
* 3. Keep processing lightweight
* - Avoid SOQL/DML in loops
* - Collect data, then do bulk DML outside loop
* - Consider queueing heavy work via Queueable
*
* 4. Handle duplicates
* - At-least-once delivery means duplicates possible
* - Use Correlation_Id__c to detect/dedupe
* - Design handlers to be idempotent
*
* 5. Monitor failures
* - Log errors to custom object for visibility
* - Set up alerts for processing failures
* - Review Event Delivery Failures in Setup
*
* ============================================================================
*/
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |