There are many way of asynchronous processing in Salesforce like Future method, Queueable Apex , Batch job, Scheduler Apex and etc. In Summer 19 release Salesforce provide another feature called "Asynchronous Apex Triggers" that can process data asynchronously with the help of Change Data Capture.
A change event trigger is an “after-insert” trigger. The trigger fires after the change event message is published. You can create an after-insert trigger in the Developer Console the same way you create an Apex object trigger after enabling the object for Change Data Capture. To enable the objects for receiving change notification follow below step :-
Setup-> Integrations -> Change Data Capture.
You can create an after-insert trigger in the Developer Console the same way you create an Apex object trigger. When you create a trigger, pick the change event object from the sObject dropdown, which is populated with the change events available in your org.
Some Important point to consider :-
Some Important Link :-
1) Salesforce blog post : https://developer.salesforce.com/blogs/2019/06/get-buildspiration-with-asynchronous-apex-triggers-in-summer-19.html
2) Release Note : https://releasenotes.docs.salesforce.com/en-us/summer19/release-notes/rn_change_event_triggers.htm
3) Trailhead module : https://trailhead.salesforce.com/en/content/learn/modules/change-data-capture/understand-change-data-capture
Thanks
Amit Chaudhary
A change event trigger is an “after-insert” trigger. The trigger fires after the change event message is published. You can create an after-insert trigger in the Developer Console the same way you create an Apex object trigger after enabling the object for Change Data Capture. To enable the objects for receiving change notification follow below step :-
Setup-> Integrations -> Change Data Capture.
Lets see how we can create the Asynchronous Apex Triggers.
You can create an after-insert trigger in the Developer Console the same way you create an Apex object trigger. When you create a trigger, pick the change event object from the sObject dropdown, which is populated with the change events available in your org.
Asynchronous Apex Trigger
trigger AsyncAccountTriggers on AccountChangeEvent (after insert) {
}
}
Some Important point to consider :-
- Here is list of supported object
- For a standard object, the change event name is StandardObjectNameChangeEvent for example AccountChangeEvent
- For a custom object, the change event name is CustomObjectName__ChangeEvent for example Employe__ChangeEvent (suffixed as __ChangeEvent)
- Asynchronous Apex triggers are change event triggers that run asynchronously after a database transaction is completed
- Available for After Insert Event only
- With Asynchronous Apex Trigger we can move complex computations and logic out of the transaction
Some Important Link :-
1) Salesforce blog post : https://developer.salesforce.com/blogs/2019/06/get-buildspiration-with-asynchronous-apex-triggers-in-summer-19.html
2) Release Note : https://releasenotes.docs.salesforce.com/en-us/summer19/release-notes/rn_change_event_triggers.htm
3) Trailhead module : https://trailhead.salesforce.com/en/content/learn/modules/change-data-capture/understand-change-data-capture
Thanks
Amit Chaudhary
No comments:
Post a Comment