+ Start a Discussion


Hi Guys,

Can someone help me out here!

This is my situation:

I have two custom objects Job_ATS__c and Shortlists__c.

Job_ATS__c is the Parent and Shortlists__c is the Child. The relationship is one to many.

That means one job can have many shortlists and each shortlist has a Status__c. Status are 'Interested' or 'Not Interested'


So what I want is a query that will return Job Name and count for Interested and Not Interested shortlists.




Job_ATS__c                      Shortlists__c                                                                           Desired Result

______________         __________________________________                       ______________________________
Job Name       id             Shortlist Name       id     job_id   Status                                   Job Name   Interested     Not Interested
______________         __________________________________                       _______________________________
Job1                 1               Shortlist1                1        1          Interested                             Job1                1                        1  
Job2                 2               Shortlist2                2        1          Not Interested                      Job2                1                        0

                                           Shortlist3                3         2          interested


I need to Display the desired result on Vf page.




Is the relationship between ob_ATS__c and Shortlists__c a master -detail ?? If yes, then I think it will be easier to get this thing done..




maja madi


No its a look up relationship



The simplest way might be to create two roll-up summary fields on the Job_ATS__c object, with roll-up types of COUNT on Shortlists__c. You would then set Filter Criteria to check for records with Statuses of Interested and Not Interested. Then, for your query, you could just write


SELECT Name, RollUpField1, RollUpField2 FROM Job_ATS__c



I didn't notice junglee's question until after I posted this. My suggestion would only work if it were a master-detail relationship.


Yes ,you can use Master detail relationship and then create Roll up summary fields name them Intersted and NotIntersted then apply coun t on that and query it..

anohter method is to use Record type..

 Hope This will help you..