2
  • 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;

3 Answers 3

3

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;
2
  • i tried this but it throw an error that List has no rows Nov 3, 2016 at 5:16
  • Use DeveloperName instead of Name Jan 28, 2019 at 21:11
5

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.

4

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

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .