function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
gslatergslater 

Standard Field not visible in Schema?

I'm trying to create an Opportunity Product (OpportunityLineItem) but for some reason it isn't accepting the Product2 field.  I know this field exists because it is standard but for some reason it isn't in the schema.  At first I thought it might have something to do with permissions but I have admin privileges and if I look at the field accessibility visibility is set to true for all profiles.  Here's the code (l is a Lead and pbe is a PricebookEntry).

 

OpportunityLineItem oli = new OpportunityLineItem();
            oli.Quantity = l.Units__c;
            oli.Roll_Call__c = l.Roll_Call__c;
           oli.Product2 = pbe.Product2Id;            //explodes here
            oli.Product_Code__c = l.Product_Code__c;
            oli.OpportunityId = leadOpportunityIds.get(l);

 

And it won't compile: Invalid field Product2 for Sobject OpportunityLineItem