Guest User

Untitled

a guest
Feb 23rd, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. trigger on Account (after insert, after update) {
  2. Account[] records = new Account[0];
  3. for(Account record: Trigger.new) {
  4. if(meetsCriteria(record)) {
  5. records.add(record);
  6. }
  7. }
  8. if(!records.isEmpty()) {
  9. System.enqueueJob(FlowCaller(records));
  10. }
  11. }
  12.  
  13. public class FlowCaller implements Queueable {
  14. Account[] records;
  15. public FlowCaller(Account[] records) {
  16. this.records = records;
  17. }
  18. public void execute(QueueableContext context) {
  19. Map<String, Object> params = new Map<String, Object> {
  20. 'accounts' => records // accounts is flow sobject collection
  21. };
  22. Flow.interview.DoSomethingCool theFlow =
  23. new Flow.Interview.DoSomethingCool(params);
  24. theFlow.start();
  25. }
  26. }
Add Comment
Please, Sign In to add comment