Another Salesforce blog!!!

Salesforce, Apex

RECORD TYPE

get recordtype id, name

SELECT Id, Name, DeveloperName FROM RecordType WHERE SobjectType = ‘obj_name__c’ SELECT Id, RecordtypeId, RecordType.name FROM obj_name__c WHERE Id = ‘012i00000015pm9AAA’

HOW TO GET LIST OF RECORD TYPE FOR THE OBJECT

How to get the record type name/id: Map<String, Id> mapOfRecordTypeAndId = getMapOfRecordTypeAndId(‘EMPLOYEE__c’); system.debug(‘//’ + mapOfRecordTypeAndId); system.debug(‘// id of the record type’ + mapOfRecordTypeAndId.get(‘recordtypename’); Util class: public static Map<String,Id> getMapOfRecordTypeAndId(String sObjectName){ Map<String , Id> mapOfRecordTypeAndId = new Map<String , Id>(); if (object_recordtypes.containsKey(sObjectName) && object_recordtypes.get(sObjectName).size()>0 ){ mapOfRecordTypeAndId= object_recordtypes.get(sObjectName); }else{ List<RecordType> recordTypeList = [SELECT Id, Name, DeveloperName FROM […]

how to get recordtype id

RecordTypeId = Schema.SObjectType.Contact.getRecordTypeInfosByName().get(‘record type name here’).getRecordTypeId();