function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
Hi,
How to get all products using opportunity id through soql?
any one help me?
Thanks in advance
Hi Devendra,
Thanks for your reply. It helped for my requirement..
You need to do a query on OpportunityLineItem and then retrieve all the products.
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_opportunitylineitem.htm
sET<Id> productIds = new Set<Id>();
for(OpportunityLineItem objOLI : [Select Id, ProductId, OpportunityId from Opportunity where OpportunityId = : 'Id Of Opportinity Goes Here']){
if(objOLI.ProductId != null){
productIds.add(objOLI.Id);
}
}
List<Product2> productList = [Select Id from Product2 where Id In: productIds];
System.debug('Product List --->'+productList);
Hope this helps :)
Thanks,
Devendra
All Answers
You need to do a query on OpportunityLineItem and then retrieve all the products.
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_opportunitylineitem.htm
sET<Id> productIds = new Set<Id>();
for(OpportunityLineItem objOLI : [Select Id, ProductId, OpportunityId from Opportunity where OpportunityId = : 'Id Of Opportinity Goes Here']){
if(objOLI.ProductId != null){
productIds.add(objOLI.Id);
}
}
List<Product2> productList = [Select Id from Product2 where Id In: productIds];
System.debug('Product List --->'+productList);
Hope this helps :)
Thanks,
Devendra
Hi Devendra,
Thanks for your reply. It helped for my requirement..