0

How to get record type Id in apex having its system DeveloperName (not a Name/Label).

UPD:

There is a similar question here https://salesforce.stackexchange.com/search?q=What+would+be+the+best+approach+to+get+the+recordtype+id but it is more general and the best answer selected may confuse searchers. This question is more specific and has a simple oneliner as a solution, which is more accurate with the current API.

0

1 Answer 1

3

For example you have RecordType on Account with name 'Person Account' and DeveloperName 'Person_Account'

acc.RecordTypeId = SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Person_Account').getRecordTypeId();
1
  • For the default Person Account Record Type it would be .get('PersonAccount')
    – MikeA
    Sep 6, 2022 at 8:39

Not the answer you're looking for? Browse other questions tagged .