Thursday 26 July 2018

Get the Developer Name for Record Types without SOQL query

Hi,

Previously, the developer name was accessible only via SOQL on the RecordType SObject, and not via describe information. Now you can use the following methods to get the developer name.


  • Schema.DescribeSObjectResult.getRecordTypeInfosByDeveloperName()
  • Schema.RecordTypeInfo.getDeveloperName()


Sample Codes:

Getting Record Type Id based on Developer Name:

Schema.DescribeSObjectResult resSchema = Department__C.sObjectType.getDescribe();
//getting all Recordtype developer names of Department__c object
Map<String,Schema.RecordTypeInfo>  recordTypeInfo = resSchema.getRecordTypeInfosByDeveloperName(); 
//Getting IT Department Record Type Id by using developer name ''IT_Department"
Id recordTypeId= recordTypeInfo.get('IT_Department').getRecordTypeId();
System.debug('recordTypeId:'+recordTypeId);

Getting RecordType Developer Name based on Name(Label):


Schema.DescribeSObjectResult resSchema = Department__C.sObjectType.getDescribe();
//getting all Recordtype developer names Account
Map<String,Schema.RecordTypeInfo> recordTypeInfo = resSchema.getRecordTypeInfosByName(); 
//Getting Business Record Type Id by using developer name 
String developerName = recordTypeInfo.get('IT Department').getDeveloperName();

System.debug('developerName:'+developerName);


Reference:

https://trailhead.salesforce.com/modules/platform_dev_i_cert_maint_sum18/units/whats_new_platform_devs


How to include a screen flow in a Lightning Web Component

 Hi, Assume  you have a flow called "Quick Contact Creation" and API Name for the same is "Quick_Contact_Creation". To i...