Below is the SOQL query that gets executed successfully in Workbench but unable to save the same query in apex code getting below error.
SELECT Quantity, Product2.ExternalId
FROM OpportunityLineItem
Where OpportunityId =: OppId
Apex code snippet
unable to save this in apex as it gives below error
opportunityLineItemList = [SELECT Quantity, Product2.ExternalId
FROM OpportunityLineItem
Where OpportunityId =: OppId];
Error No Such column 'ExternalId' on entity Product2
FLS is been given to the field