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
sami31sami31 

Query on parent child related objects

Hi,
There are 2 objects Account &Address and the relationship is master detial. In address there is a checkboox called primary and most of the account will have 1 address which is marked as primary. I want to know the accounts which don't have a primary address at all. For example there are 2 accounts A & B. Account A has 5 addresses and none of them have primary checked and Account B has 5 address in which 1 is primary and the other 4 non primary. So when a run a report saying primary=false i am getting both accounts A(5 records for each non primary address) & B(4 records for each non primary address) instead of only account A. This is because B has 4 addresses which are not primary and report is pulling them.
Is there any different way or query where i can get only account wiht no primary address which means by our example only account A should come out but not acount B.
Thanks.
GauravGargGauravGarg

Hi Sameer,

Try putting the account name in filter condition.

Thanks,

Gaurav
Email: gauravgarg.nmims@gmail.com
Skype: gaurav62990

sami31sami31
Hi Gaurav,
Sorry i didn't get your point. If you mean to add the account name manually in report filter then i think you misunderstood my requirement. In my org I assume there will be good amount of accounts  without primary checkbox(not even single address marked as primary), so i want to know all such accounts without single child address marked primary.

Any suggestions??

Thanks,
GauravGargGauravGarg
Hi Sameer,

The above requirement can be fulfilled via Rollup summary field on Account object, that will count the child object has any Primary address field as true, Please find below article to create rollup summary field.

https://success.salesforce.com/answers?id=90630000000h0EZAAY

Once the Roll-up summary field is created, please add the this field in filter criteria.

Hope this will solve your problem. 

Thanks,
Gaurav
Email: gauravgarg.nmims@gmail.com
skype: gaurav62990