Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trigger on Account (after insert, after update) {
- Account[] records = new Account[0];
- for(Account record: Trigger.new) {
- if(meetsCriteria(record)) {
- records.add(record);
- }
- }
- if(!records.isEmpty()) {
- System.enqueueJob(FlowCaller(records));
- }
- }
- public class FlowCaller implements Queueable {
- Account[] records;
- public FlowCaller(Account[] records) {
- this.records = records;
- }
- public void execute(QueueableContext context) {
- Map<String, Object> params = new Map<String, Object> {
- 'accounts' => records // accounts is flow sobject collection
- };
- Flow.interview.DoSomethingCool theFlow =
- new Flow.Interview.DoSomethingCool(params);
- theFlow.start();
- }
- }
Add Comment
Please, Sign In to add comment