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
VRK1VRK1 

query help in salesforce

Hi 
my requirement is i need to query 
OpportunityLineItem and  Resourse__c from 'Opportunity'   object .

i can query OpportunityLineItem from Opportunity but not fetching 'Resource__c ' object .
**********
Select Id, Name,(Select Id,TotalPrice, PricebookEntry.ProductCode,PricebookEntry.Name,(select id,name from Resourse__c) From OpportunityLineItems) From Opportunity Where Id = 'xxxxxxxxx'
************
can you pls check and let me know how to query on opportunity and fetch both OpportunityLineItems & Resourse__c.

Thanks
VRK

 
Sai PraveenSai Praveen (Salesforce Developers) 
Hi ,

What is the relation between Opportunity and Resource. Is Resource object child of the opportunity line items .

Thanks,
 
VRK1VRK1
Thanks praveen your response.
Yes , Resource object is child for opportunity line items...
 
Sai PraveenSai Praveen (Salesforce Developers) 
Hi ,

You cannot write a subquery inside a subquery. Instead of that you may need to write the query on Opportunity line items and get the opportunity fields using Opportunity.Name and Resourse field as sub query.

Please find the below link which helps you to understand more on it.

https://shreysharma.com/multi-level-relationships/

If this solution helps, Please mark it as best answer.

Thanks,