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
Melanie Miller 11Melanie Miller 11 

Opportunity Products related list on Account Page

I have a related list on the Account page layout (see image) that shows the products that are associated with opportunities. (Accomplished via a lookup relationship on the Opportunity Product object) However, it shows the products from ALL Opportunities, and we only want to see these details for closed won Opps. What is the best way to get the products from open or lost Opps filtered out of this list? (We definitely want to use a related list solution and not Assets on the Account object.)

User-added image
Demand Chain SystemsDemand Chain Systems
Hi Melanie,

You could look at adding a custom lookup field from the Opportunity Product to the Account record, and only set it once an Opportunity is marked as Closed Won.  Then, you'd find the child relationship pertaining to that lookup and add it to the Account page layout.

Otherwise, you're likely looking at an inline Visualforce page (using the Account as a Standard controller and an Apex extension class to handle the filtering).  Alternatively, if you're looking to switch to Lightning Experience, you could look at implementing it as a Lightning Component.

Hope that helps,
- James Loghry
 
Melanie Miller 11Melanie Miller 11
Thanks James! Your suggestion gave me the idea to get rid of the trigger that was auto-populating the account name into each Opportunity line item (that's how I got the line items to show up on the Account page in the first place) and replace it with workflow processes instead. For anyone who's interested, the process now auto-populates the account when the Opp status is Closed Won, and clears it out during an open or lost status. That way, only won Opps show up on the Account page and my VPs are happy. :)
Courtney LisowskiCourtney Lisowski
Melanie!!! Can you please walk me though how you were able to create your opportunity products on the account page through a lookup field. Is it an object? We are trying to replicate exactly what you did! anything would help!
Melanie Miller 11Melanie Miller 11
Hi Courtney, yes, Opportunity Products is an object. You can find it listed in the setup section underneath Opportunties. You'll can bring it onto the Account page via a lookup field on the Account object.
Chris - ARIChris - ARI
How would you do this part?

You could look at adding a custom lookup field from the Opportunity Product to the Account record, and only set it once an Opportunity is marked as Closed Won.  Then, you'd find the child relationship pertaining to that lookup and add it to the Account page layout.
Kerrie CardenKerrie Carden
" For anyone who's interested, the process now auto-populates the account when the Opp status is Closed Won, and clears it out during an open or lost status."
I wanted to follow up on Chris' question, Melanie - how did you do this as field updates do not seem to work on lookup relationships? 
Melanie Miller 11Melanie Miller 11
Kerrie, I'm pretty sure I had set this up through process builder. We actually ended up going a completely different direction with this and don't even use Opportunity Products at all now, so I don't remember the details of how I had gotten that working. It was probably set to run a process whenever the opportunity was edited though, that set or cleared the account name in the lookup field depending on the stage. Hope that helps!
Anthony Kelly 7Anthony Kelly 7

Hi Melanie,

I am interested in setting up something similar in our org...I was wondering if you would be able to share the VisualForce code you used to create this section?

Thank you!

Melanie Miller 11Melanie Miller 11
Hi Anthony, I actually ended up simply using a filter in the lookup field settings to tell it to only include closed won opportunities. Hope that helps! Melanie Miller Revenue Operations Specialist 503-505-2623 mmiller@bizlibrary.com [1512678866271_image001.png]
Anthony Kelly 7Anthony Kelly 7
It does. Thanks for the super quick reply Melanie!!
Paul BlomerthPaul Blomerth

Hi Melanie,

Quick question on this: how did you create the related list on the account object? I'm looking to implement exactly what you took the screenshot of, and then modifying it to only return prodcts from closed-won opps.
 

Thanks!

Paul

Melanie Miller 11Melanie Miller 11
To get a related list on the Account page you'll need to set up a lookup relationship on the Opportunity Product object. From there it should prompt you through the rest of the steps!
Paul BlomerthPaul Blomerth
Thanks, Melanie! I figured it out!
Melanie Miller 11Melanie Miller 11
I added it onto the page layout, if you scroll down a little in that upper section you'll see an option to add related lists to the page! Melanie Miller Revenue Operations Specialist 503-505-2623 mmiller@bizlibrary.com [1512678866271_image001.png]
Melanie Miller 11Melanie Miller 11
Hi Jesse, it sounds like you might be trying to add it as an Account field. Try adding the lookup field to the Account on the Opportunity Product object, not on the Account object. (Lookups should be created on the child object)
Jesse ShaoJesse Shao
Melanie, I was able to get an Opportunity Product Object on my Account, but it is not pulling any data in like yours. CAn you advise on how you got it to do that? 
Melanie Miller 11Melanie Miller 11
You probably just need to create a way for the lookup field (the account, essentially) on the Opportunity Product to get populated. For past Opp Products, you could either manually update them or do a mass update for your new field. Going forward, you could set up an automated process (via workflow rules, process builder, etc) to populate the account name when a new product is created on the Opportunity. Does that answer your question?
Michaël BENSAIDMichaël BENSAID
HI Thanks a lot for this problem, 
@Melanie when you say :   I actually ended up simply using a filter in the lookup field settings to tell it to only include closed won opportunities.
i try to filter in the look up product opportunity but i don't have the stage in account. How do you do ? thanks a lot