We get this script exception (in managed package) emailed from a customer instance.
Apex script unhandled trigger exception by user/organization:
XXXXX/YYYYYpkg1.ProductOppStockCheck: execution of BeforeUpdate
caused by: System.QueryException: sObject type 'OpportunityLineItem'
is not supported.
It seems below line is causing this exception.
List<OpportunityLineItem> oppLineItemList = [SELECT Id, OpportunityId, Quantity FROM OpportunityLineItem WHERE OpportunityId IN :oppList AND PricebookEntry.Product2.pkg1__Is_Flagged__c = TRUE];
But this error doesn't seem to occur in Dev. or our testing Enterprise edition orgs.
Any reason why OpportunityLineItem is not supported in a Enterprise Ed. org.?
Any thoughts, suggestions to find root cause are welcome.
Thanks.
Best Answer
Please check your class declaration : 'with/without sharing'.
Here is a similar issue -> https://developer.salesforce.com/forums/?id=906F000000090ZPIAY.
Below is an explanation by the person having the issue who got it resolved later on:
Hope this helps.