Automation: Triggering the SDK via Platform Events
Why?
What: The Event-Driven Architecture
Solve: Implementation Steps
trigger OpportunityTrigger on Opportunity (after update) {
List<Document_Request__e> docEvents = new List<Document_Request__e>();
for (Opportunity opp : Trigger.new) {
// Only trigger if the Stage changes to 'Closed Won'
if (opp.StageName == 'Closed Won' && Trigger.oldMap.get(opp.Id).StageName != 'Closed Won') {
docEvents.add(new Document_Request__e(
Record_ID__c = opp.Id,
Template_ID__c = '00Xxxxxxxxxxxxx' // Your Template ID
));
}
}
if (!docEvents.isEmpty()) {
EventBus.publish(docEvents);
}
}Technical Benefits
⚠️ Constraints
Last updated
Was this helpful?

