I have the following block of code and when i execute it from the developer console using anonymous window it is working fine without any error, But it's strange when i copy the same thing in apex class it is giving an compilation error.
Map<Id, Schema.RecordTypeInfo> recordTypeByIdMap = Schema.SObjectType.Contact.getRecordTypeInfosById();
Map<String,String> conversionMap = new Map<String,String>();
for(String r:recordTypeByIdMap.keySet())
{
if(!recordTypeByIdMap.get(r).getDeveloperName().startsWithIgnoreCase('Create_'))
{
conversionMap.put('Create_'+recordTypeByIdMap.get(r).getDeveloperName(),r);
}
}
System.debug('-------------'+conversionMap);
And here is the error I am getting after copying same code the apex class:
"Method does not exist or incorrect signature: void getDeveloperName()
from the type Schema.RecordTypeInfo"
Let me know anyone else has faced the same error or someone can give some feasible solution.
Best Answer
In order to have
getDeveloperName()
method available, API version of the class should be 43.0 for now.Check Summer '18 release notes