function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Phuc Nguyen 18Phuc Nguyen 18 

Determine if record type exist

Hello All,
Looking to get the Recordtype off an objetc but was wondering what woul di do if the name was changed?
 
accountRTId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('First load').getRecordTypeId();
Is there a better way to do this to make sure this doe snot throw an exception if a user changes the name?

Thanks,
P
 
David Zhu 🔥David Zhu 🔥
You may have to use soql to avoid throwing exception if record type name is changed.

list<RecordType> recordtype = [Select Id From RecordType Where SobjectType='Account' And DeveloperName = 'First_Load' Limit 1];

if (recordtype.size() == 1){
    
}