8

Our product comes with a couple objects including RecordTypes. In our customer org I'm adding some RecordTypes and experienced, that I can give them names that the packaged types already have. So now I have two RecodTypes with the developer name "BuggyRecordType", they only differ in there NamspacePrefix. Thats fine so far.

But when I try to use the new getRecordTypeInfosByDeveloperName() method, it only returns my new Record Type and the other one is just skipped. This doesn't feel right to me.

The recodTypeInfoByDevName map in my example for sure only contains it once, since the key would be the same. Another issue here is, that I don't even see the namespace prefix in the RecordTypeInfo object.

Map<String, RecordTypeInfo> recodTypeInfoByDevName = SObjectType.Account.getRecordTypeInfosByDeveloperName();

for(String devName : recodTypeInfoByDevName.keySet()) {
    System.debug(recodTypeInfoByDevName.get(devName));
    System.debug([SELECT DeveloperName, NamespacePrefix FROM RecordType WHERE DeveloperName = :devName]);
}

Results in:

Schema.RecordTypeInfo[getDeveloperName=BuggyRecordType;getName=Buggy Record Type;getRecordTypeId=012C0000000CGtyIAG....]

(RecordType:{DeveloperName=BuggyRecordType, NamespacePrefix=PKG, Id=012C0000000IIIaIII}, RecordType:{DeveloperName=BuggyRecordType, NamespacePrefix=NEW, Id=012C0000000CGtyIAG}

Is there any way to avoid SOQL here? If not it feels like the whole feature is useless, since you never know, what the customer does...

6
  • 1
    Is fetching by the developer name (i.e. getRecordTypeInfosByName()) not an option? If you truly do need the label, would RecordTypeInfo.getName() not work after fetching by developerName?
    – Derek F
    Commented Sep 27, 2018 at 12:44
  • 3
    Since the customers can also set the names, it would result in the same issue. I don't need the label in general, mostly I just need the record type id. So customers could override my record types by defining their own, that feels so wrong, since developer names should always be unique, so we can rely on them..
    – itsmebasti
    Commented Sep 27, 2018 at 13:39
  • 2
    I just did a lot of digging and couldn't come up with anything either. Looks like you found yourself a system bug. It's not on the known issues list yet. Time for your 10 minutes of fame! ;) Commented Sep 29, 2018 at 2:39
  • 1
    also: if there is a custom record type named "Master" - getRecordTypeInfosByName will return the system "Master" not the custom one. Query will return only the custom one. Commented Mar 4, 2019 at 15:53
  • 1
    I raised this on the partner forums when I too discovered this gap in the API.
    – Phil W
    Commented Jun 28, 2021 at 12:40

0

You must log in to answer this question.

Browse other questions tagged .