Skip to main content
Hi,

Below is my code. Hope there is some mistakes while getting the errors string from the map for corresponding records.

 

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

 
1 réponse
  1. 5 mars 2015, 10:13
    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