2

We have below describe call to get the record type id by name.

Id recordTypeId = Schema.SObjectType.Case.getRecordTypeInfosByName().get('RECORD_TYPE_NAME_NOT_DEVELOPER_NAME').getRecordTypeId();

This gives the id of the record but this logic is based on label of the record type instead of developer name. That means if we change the Label of record type then any code using such mechanism will break.

I know we can make a query to get the record type id by developer name but that will cost me a SOQL which I don't want to.

Is there any describe call to get the record type id by developer name without making the SOQL?

1
  • Why it was marked as a duplicate? This is completely opposite question. Previous one is about 'Getting Developer Name By Id' This on is about 'Getting ID by Name' Commented Sep 18, 2019 at 15:08

1 Answer 1

3

Seems like the APIs are not supporting this, but there is an Idea for exactly this use case: Get RecordTypeInfos by API name method

Some related questions:

6
  • 1
    This is under review, so at least there's Hope for the future.
    – sfdcfox
    Commented Nov 13, 2017 at 23:04
  • I thought I saw a tweet that there would be some progress in an upcoming release, but I can't recall exactly what it said.
    – Adrian Larson
    Commented Nov 13, 2017 at 23:38
  • 1
    @AdrianLarson Yeah, someone leaked a pic of the Apex Code road map. Forward-Looking Statement and all that, but here's hoping.
    – sfdcfox
    Commented Nov 13, 2017 at 23:44
  • Thank you. I think then we need to wait for salesforce to provide such methods. Commented Nov 14, 2017 at 3:01
  • Now you can use getRecordTypeInfosByDeveloperName() which was made available in Summer'18. developer.salesforce.com/docs/atlas.en-us.apexcode.meta/…
    – MikeA
    Commented Aug 6, 2019 at 11:14

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