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
kapil pkapil p 

Multiple child-parent lookup relationship in SOQL-APEX

Hello Devs,

I want to access data from below child parent dependencies:

Object tnw_invoice__InvoiceItem__c connected with Object OrderItem and OrderItems connected with Orders

I'm trying to add WHERE condition like Order.Status != 'Closed Lost' in below query:

SELECT Id, tnw_invoice__Order_Item__c FROM tnw_invoice__InvoiceItem__c WHERE tnw_invoice__Product_Code__c = 'xxxxxxxxx8989'

But it's give me error of "Didn't understand relationship......." on developer console query editor.

Thanks for help :)

Kapil
Nayana KNayana K
It should be something like   tnw_invoice__Order_Item__r.  tnw_invoice__Order_r.Status != 'Closed Lost'


please check relationship name first before you proceed and apply properly 
Sharad SoniSharad Soni
Hi Kapil,

The required WHERE clause will be

WHERE tnw_invoice__Order_Item__r.  tnw_invoice__Order__r.Status != 'Closed Lost' .

Thanks.

Regards 
Sharad