2

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.

2
  • 3
    what is an API version of the class ? Jul 18 '18 at 7:07
  • ... i.e. change the API version for the class to 43.0 as this is a recent addition.
    – Keith C
    Jul 18 '18 at 7:11
8

In order to have getDeveloperName() method available, API version of the class should be 43.0 for now.

Check Summer '18 release notes

Schema.RecordTypeInfo Class

New Method

getDeveloperName()

Returns the developer name for this record type.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.