• Record Type Label: Lead/Opportunity Rule
  • Record Type Name: Lead_Opportunity_Rule

throw an error Compile Error: Initial term of field expression must be a concrete SObject: String

 String recType = Schema.SObjectType.Assignment__c.getRecordTypeInfosByName().get('Lead_Opportunity_Rule').getRecordTypeId();
             //Assignment Record
                Assignment__c objass = new Assignment__c();
                objass.FE_Code__c = fobj.id;
                objass.Partner_ID__c = fobj.id;
                objass.Lead_Rule_Type__c = 'PartnerID';
                objass.RecordType = recType.name;
                insert objass;

You get record type Id, you cannot extract name from it.

RecordType rt = [SELECT Id FROM RecordType WHERE sObjectType = 'Assignment__c' AND Name = 'Lead_Opportunity_Rule'];
objass.RecordType = rt;
// OR
objass.RecordTypeId = rt.Id;
  • i tried this but it throw an error that List has no rows Nov 3 '16 at 5:16
  • Use DeveloperName instead of Name Jan 28 '19 at 21:11

You should assign the lookup as follows:

objPass.RecordTypeId = recType;

A String instance does not have the Name property.

You might confuse yourself less with clearer naming here, using instead recTypeId, for example.


Change this line objass.RecordType = recType.name; to this: objass.RecordTypeId = recType ;


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.