Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to get recordType Id's without using a SOQL query (source how-to-get-record-type-id-without-soql):

// User need to pass two parameters SObject Type & 
// RecordType Label ( not Record Type Developer Name)
public static Id getRecordTypeId(String ObjectType, String RecordTypeLabel)
  SObject OBJ;
  // Describing Schema
  Schema.SObjectType Res = Schema.getGlobalDescribe().get(ObjectType);
  if (Res != null)

      OBJ = Res.newSObject();
      // Describing Object 
      Schema.DescribeSObjectResult DesRes = OBJ.getSObjectType().getDescribe(); 

      if(DesRes != null){
        // Get a map of fields for the SObject Save error: unexpected token: 'map'
        map <string schema.recordtypeinfo="schema.recordtypeinfo"> RecordTypeMap = DesRes.getRecordTypeInfosByName();
        if (RecordTypeMap != null) 
            Schema.RecordTypeInfo RecordTypeRes = RecordTypeMap.get(RecordTypeLabel);
            if (RecordTypeRes != null) {
                return RecordTypeRes.getRecordTypeId();
     return null;

But on the line map <string schema.recordtypeinfo="schema.recordtypeinfo"> RecordTypeMap = DesRes.getRecordTypeInfosByName(); I am getting an error Unexpected token: 'map'

What have I done wrong, I've tried re-writing it

share|improve this question
up vote 5 down vote accepted

Try to change that to this:

Map<String, Schema.RecordTypeInfo> RecordTypeMap = DesRes.getRecordTypeInfosByName();
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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