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
Phuc Huynh 1Phuc Huynh 1 

how to subquery with this relationship External object (External Lookup Relationship)?

Hi all, 
Currently i have two External object with relationship External Lookup Relationship with A__x is parent B__x is child. B have 5 records.
From A__x  i want to query B__x just one query
Select id, name ,(Select id, name from B__r ) where id = '123456789'. But result of child is null?
Can you help me find to query child record success?
In order to avoid the error, you will need to instead edit one of the existing SYNCED fields and specifically Change the Field Type so that it is of the External Lookup Relationship type and that it points to the correct external table object. Then, you can perform your SOQL query and get no errors. 

Phuc Huynh 1Phuc Huynh 1
thanks  @@@we@@@, but i configed by the same with document guide External Lookup Relationship type .... I think i missing somethings about config :( 
hmm try to  update your config  update or can you provide  sceerenshot 
Phuc Huynh 1Phuc Huynh 1
Hi @@@we@@@, can you help me how to  write Test Class for External object Data?
i have some class use data from exteral object for logic code. I saw that someone use mockrequest.
But i need to query records into my classes it's not working with the same solution. How to insert and use records external object in @testSetup
? Please help me about this case. 
Ajay K DubediAjay K Dubedi
Hi Phuc,

You Missed From A__x .
Use below Query instead of Select id, name ,(Select id, name from B__r ) where id = '123456789'.

    SELECT Id, Name ,(SELECT Id, name FROM B__r ) FROM A__x WHERE Id = '123456789'.  
And Id should be valid.

For Eg:  SELECT Id,Name,(SELECT Id ,Name FROM Contacts) FROM Account WHERE Id = '0010o00002H9oVOAAZ'

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Ajay Dubedi