
Map<String, List<Account>> errorRecords = new Map<String, List<Account>>();
List<Account> accError = new List<Account>();
if((record.Discount_Type__c == 'Date Specified' || record.Discount_Type__c == 'Life Time') && opps.Coupon_Codes__c == null)
{
accError.add(record);
errorRecords.put(' Please provide coupon code for the discount type specified!', accError);
}
else if(record.Discount_Type__c == 'Date Specified' && String.valueOf(record.Discount_End_Date__c) == null)
{
accError.add(record);
errorRecords.put(' Please choose the discount end date in account before clone the new opportunity', accError);
}
Here I am adding the error messages to record
for(String str : errorRecords.keySet())
{
for(Account o : errorRecords.get(str))
{
Account oAccErrors = accountNewMap.get(o.Id);
oAccErrors.addError(str);
}
}
Error records is seperated perfectly but the error message is displaying as same. Thanks in advance

Hi,else if(record.Discount_Type__c == 'Date Specified' && String.valueOf(record.Discount_End_Date__c) == null){accError.clear();accError.add(record);errorRecords.put(' Please choose the discount end date in account before clone the new opportunity', accError);}Thank you