Guest User

Untitled

a guest
Feb 21st, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. trigger prevent1358 on account (before insert) {
  2. if(Trigger.new.size() == 8) {
  3. Trigger.new[0].addError('You have been blocked.');
  4. Trigger.new[2].addError('You have also been blocked.');
  5. Trigger.new[4].addError('Sorry. You are BLOCKED.');
  6. Trigger.new[7].addError('So sorry. You. Are. Blocked. Ha!');
  7. }
  8. }
  9.  
  10. Account[] records = new Account[8];
  11. for(Integer index = 0; index < 8; index++) {
  12. records[index] = new Account(Name='Account '+(index+1));
  13. }
  14. Database.SaveResult[] results = Database.insert(results, false);
  15. System.assertEquals(false, results[0].isSuccess());
  16. System.assertEquals(false, results[2].isSuccess());
  17. System.assertEquals(false, results[4].isSuccess());
  18. System.assertEquals(false, results[7].isSuccess());
  19.  
  20. trigger preventRecord0 on account (before insert) {
  21. Trigger.new[0].addError('Blocking the first record.');
  22. }
  23.  
  24. Account[] records = new Account[8];
  25. for(Integer index = 0; index < 8; index++) {
  26. records[index] = new Account(Name='Account '+(index+1));
  27. }
  28. // Too many retry errors
  29. Database.SaveResult[] results = Database.insert(results, false);
Add Comment
Please, Sign In to add comment