+ Start a Discussion

How to search on child object field

Hi. I'm a newbie, so this may be a simple question to answer.


I have 2 custom objects: an Application (e.g. for a mortgage), and Client, connected by a lookup relationship. An application can have 1 or more Clients, and the Client includes fields First_Name & Surname (Text, External ID) and ApplicationLUP (Lookup(Application)).


When I click on my Applications tab and search for an Application in the search field (left hand bar), I'd like to be able to search by name of the child Client, first name or surname,as well as Application ID. So searching for "Smith" will return me all Applications with a Client named Smith. How is this done?


Many thanks!


Siddhesh KabeSiddhesh Kabe

How about writing a SOSL query for the same, or even better, write a custom Visual force page for a custome search.


A standard SOQL query will do.


Hi Richard,
From my trials you will not be able to search for a parent record using the values for fields of the child record. Even your custom SOQL queries will not be able to provide this.
If you are able to get this going, I will be very interested in knowing your solution.
Steadfast Global

Siddhesh KabeSiddhesh Kabe

Hi Krishnadas,

We can always write a apex class to do the job, I had done the same on Account and Opportunity object. Its very easy to do it as you always have a ParentID in your child object.





Siddhesh KabeSiddhesh Kabe
I do agree its not an out of box functionality...but it is definately achievable.
Siddhesh KabeSiddhesh Kabe

I am not sure if this functionality is possible or not with the left hand side search box, but you can override the view to add your own custom VF page to achieve this functionality.


Sample Algorithm:


1)Build a VF page with a InputText Field.

2) On Search CommandLink Action fire a SOQL query on Child Object.

3) Select the appropriate field

4) Fire a SOQL query on Parent object with the field value.

5) Display result.


Hope it helps,