I was trying to create a trigger where if there are 3 consecutive characters then it will not allow. But it is not working. Herewith I have attached my trigger:
public class TaskHandlerController {
public static void onBeforeInsert(List<Task> TaskList){
Set<String> taskID = new Set<String>();
for(Task a: TaskList){
taskID.add(a.Id);
}
List<Task> updatePurpose = [SELECT Id, Purpose__c, Subject,Description FROM Task WHERE Id IN : taskID];
Map<String,Task> CommentMap = new Map<String,Task>();
for(Task a : updatePurpose){
if(a.Description == 'aaa'){
CommentMap.put(a.Description,a);
}
}
for(Task a: TaskList){
if(a.Description == 'aaa'){
a.addError('Your custom error message');
}
}
}
}