+ Start a Discussion

SOQL Question Help needed.

Parent object : Activity

Child Object : Claim (status is field in claim which can have values Cancelled / Closed).


Get all activities in SOQL for which all claims are closed / Cancelled.




Please try the following query.
Select (Select Status From Tasks where Status='Completed') From [CustomObject__c]

Srikanth. K

I am concened with checking of all records. exp:- there are 10 records in the object out of which 7 are cancelled / Closed then it will give me 7 records but I want query to give me 0 records as all 10 are not cancelled / Closed. (Need to check all records) 

Even before I start answering your query.
Here are few concerns:-
1.Is the Activity object referred by you the standard SFDC object?
2. If yes- then you cannot assign Activity as a parent of any object rather Activity/ Task cannot be linked by any relationship Master or lookup to any other object.
3. If no that is Activity is a custom object then - then if they linked by master-detail relationship then perhaps by using rollup summary fields ( one counting claims and other counting only claims which are closed) will enable you to get all the "Activity" in a simple query where "Count all claim" = "Count closed claim" ..
Do let me know if resolves your issue.