I'm making a validator that returns an error. I'd like to show the user A good looking name like Missing Example Error instead of Missing Example_Error__c. Below is my code, yet it still prints Example_Error__c.
for (String key : validators){
if(!validationKeys.contains(key)){
string newkey = key.replace('__c','').replace('_',' ');
if(errorMap.keySet().contains('Deal')){
errorMap.get('Deal').add('Missing '+newkey);
}else{
List<String> tempList = new List<String>{'Missing '+newkey};
errorMap.put('Deal',tempList);
}
}
}
I originally had it like key = key.replace(...); but switch to explicitly making a new string as newkey. Still isn't returning the desired result.
Am I missing something?