0

I have a custom Button on my Opportunity Page Layout which redirects to a visual force page where I have to send mail to client depending on the Opportunity Record Type name. Now how to access the current record's recordtype name from my page controller ?

2

Record Type Name can be queried using SOQL.

Id oppId = Apexpages.currentPage().getParameters().get('Id');

List<Opportunity> oppList = [Select Id, Name, RecordType.Name from Opportunity where Id =: oppId];
if(oppList.size() > 0){
    System.debug('###'+oppList[0].RecordType.Name);
}
|improve this answer|||||
0

Example for RecordType information without using any SOQLs for Case. Depending of entry data, map can be reversed and built as (RecordTypeName:RecordTypeID).

List<Schema.RecordTypeInfo> caseRecordTypeInfo = Schema.getGlobalDescribe().get('Case').getDescribe().getRecordTypeInfos();
Map<id,String> caseRecordMap = new Map<id,String>();
for(Schema.RecordTypeInfo rtInfo: caseRecordTypeInfo)
{
    caseRecordMap.put(rtInfo.getRecordTypeId(),rtInfo.getName());
}
caseRecordMap.get(recordTypeID);  //returns RecordTypeName

Or if you already selecting your object you can just add RecordTypeId and RecordType.Name to your SOQL query.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.