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
NjangaNjanga 

Query

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.

 

E.g...

 

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.

jungleeejungleee

Hi

 

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..

 

Regards

Sam

maja madi

NjangaNjanga

No its a look up relationship

 

CheyneCheyne

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

 

 UPDATE:

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

sandeep87sandeep87

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..