RECORD TYPE
get recordtype id, name
1 2 3 |
SELECT Id, Name, DeveloperName FROM RecordType WHERE SobjectType = 'obj_name__c' SELECT Id, RecordtypeId, RecordType.name FROM obj_name__c WHERE Id = '012i00000015pm9AAA' |
Favorite
HOW TO GET LIST OF RECORD TYPE FOR THE OBJECT
How to get the record type name/id:
1 2 3 4 |
Map<String, Id> mapOfRecordTypeAndId = getMapOfRecordTypeAndId('EMPLOYEE__c'); system.debug('//' + mapOfRecordTypeAndId); system.debug('// id of the record type' + mapOfRecordTypeAndId.get('recordtypename'); |
Util class:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
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 RecordType WHERE SobjectType =:sObjectName LIMIT 100]; if(recordTypeList != null && recordTypeList.size() > 0){ for(RecordType recTyp:recordTypeList){ mapOfRecordTypeAndId.put(recTyp.DeveloperName, recTyp.Id); } } object_recordtypes.put(sObjectName, mapOfRecordTypeAndId); } return mapOfRecordTypeAndId; } |
Favorite
how to get recordtype id
1 |
RecordTypeId = Schema.SObjectType.Contact.getRecordTypeInfosByName().get('record type name here').getRecordTypeId(); |
Favorite