Salesforce AddError

First,let's have a look at Salesforce API about adderror:

    

Notice that the first word is 'Marks', means this function will not stop any script.

I wrote a trigger for test this.

trigger testAddError on Account (before update) {
	integer i = 0;
	for(Account a :trigger.New){
		system.debug('before test error'+ i);
		if(i == 0)
			a.name.adderror('testError' + i);
		system.debug('after test error'+ i);
		i++;
	}
	

}

then I update a Account. here is the log

12:57:24:091 USER_DEBUG [4]|DEBUG|before test error0
12:57:24:091 USER_DEBUG [7]|DEBUG|after test error0



zhubaotian

Share this article