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
NJDeveloper019NJDeveloper019 

Creating view based on related list

I want to create a new view for accounts.  There is a related list attached to the account object by way of a lookup field in a "discounts" custom object.  My problem is I want to create a new view that will show all accounts thats don't have any discounts.  So I need to check whether the discounts related list is empty or not.  I do not see how to do this and I'm not sure it's even possible, but this is a very important feature in our system.  Can anybody give me some insight into this?

 

Thanks,

 

Ralph

werewolfwerewolf
Have you considered adding a rollup summary field to Account that counts the number of discounts under it?  Then you could make your view consider whether that field equals 0.
NJDeveloper019NJDeveloper019
While I had not considered using a rollup field, I did consider the possibility of having a field that held the count of records in the discounts related list.  My problem though is that Account and Discounts are not in a Master/Child relationship and just a standard relationship.  Is there a way to build a rollup field on a standard lookup relationship?
werewolfwerewolf
Only with an Apex trigger.  But why not just make them master/detail?  It seems like the discount cannot and should not exist without the account...