Solution Approach – We need to use describe SObject for this.
Sample Code -
//To get the record Type Id for Account – Record Type Name is “Person Account” //Get all the Record Types of Account and store it in a map. Map <String,Schema.RecordTypeInfo> recordTypes = Account.sObjectType.getDescribe().getRecordTypeInfosByName(); //Get the record type id of from the Map based on the Name Id RecTypeId = recordTypes.get('Person Account').getRecordTypeId());
No comments:
Post a Comment