+ Start a Discussion
Paweł WoźniakPaweł Woźniak 

Schema getRecordTypeInfosByDeveloperName() method does not exists.

Hi.

Happy about finally delivering option to get recordId by developer name, see relase info https://releasenotes.docs.salesforce.com/en-us/summer18/release-notes/rn_apex_developer_name.htm I wanted to use it. It works perfectly on Anonymous execution, however if used in apex class it is not possible to save due to method does not exists error.
Id devRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('PersonAccount').getRecordTypeId();
System.debug(devRecordTypeId);
In anonymous execution it returns a value in debug. Using in apex class gives an error:
Method does not exist or incorrect signature: void getRecordTypeInfosByDeveloperName() from the type Schema.DescribeSObjectResult
Do we have SF peoples here? Can you please fix it.
 
Best Answer chosen by Paweł Woźniak
Dushyant SonwarDushyant Sonwar
User-added image

Hi Paweł ,
Click on Edit and Change your apex class version to 43 by switching to version settings tab .


Hope this helps.

All Answers

Prashant Pandey07Prashant Pandey07
Id devRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('PersonAccount').getRecordTypeId();
System.debug(''+devRecordTypeId);


Please make sure your org is updated to Version 43..

--
Thanks,
Prashant
Greg CooganGreg Coogan
That code works in an Apex class for me.
User-added image

User-added image

I put it in the constructor of an Apex Class.

I don't think its a bug in Salesforce if it is working for me. I was using a sandbox on CS53.
Dushyant SonwarDushyant Sonwar
User-added image

Hi Paweł ,
Click on Edit and Change your apex class version to 43 by switching to version settings tab .


Hope this helps.
This was selected as the best answer
Paweł WoźniakPaweł Woźniak
Yes that was it, class was v42. Thanks.