Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trigger prevent1358 on account (before insert) {
- if(Trigger.new.size() == 8) {
- Trigger.new[0].addError('You have been blocked.');
- Trigger.new[2].addError('You have also been blocked.');
- Trigger.new[4].addError('Sorry. You are BLOCKED.');
- Trigger.new[7].addError('So sorry. You. Are. Blocked. Ha!');
- }
- }
- Account[] records = new Account[8];
- for(Integer index = 0; index < 8; index++) {
- records[index] = new Account(Name='Account '+(index+1));
- }
- Database.SaveResult[] results = Database.insert(results, false);
- System.assertEquals(false, results[0].isSuccess());
- System.assertEquals(false, results[2].isSuccess());
- System.assertEquals(false, results[4].isSuccess());
- System.assertEquals(false, results[7].isSuccess());
- trigger preventRecord0 on account (before insert) {
- Trigger.new[0].addError('Blocking the first record.');
- }
- Account[] records = new Account[8];
- for(Integer index = 0; index < 8; index++) {
- records[index] = new Account(Name='Account '+(index+1));
- }
- // Too many retry errors
- Database.SaveResult[] results = Database.insert(results, false);
Add Comment
Please, Sign In to add comment