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
jostendjostend 

Contact/Opportunity rollup data

What is the best way to show a sum of the product/amount on the contact page?  For example, I want to show the account name, opportunity owner, product, sum(amount), account.city, account.state in a list on the contact page. 
jpizzalajpizzala
How does the Contact record know which Opportunity it should be looking at?  Do you have a custom field that links the two?  Are you implying the relationship with the Opportunity Contact Roles records?

Unless you are planning on using Opportunity Contact Roles or a custom relationship, the Contact record is ignorant of the Opportunity's existence since both Opportunity and Contact are children of the Account object (one-to-many relationship from Account to Contacts and one-to-many relationship from Account to Opportunities).

The Account information is easy enough to pull down to the Contact record since it is the immediate parent object.  To do this, use cross-object formula fields to grab the Account field values into your Contact detail.

Considering that you posted this in the Visualforce area, however, I imagine that you are doing something completely custom with the layouts.  Could you elaborate a bit more on how your Visualforce page is (or will be) set up?
jostendjostend

I am using Opportunity Contact Roles.  Therefore I can see the oppotunities that a contact is responsible for.  However, the request I have is to display the opportunity data summarized by product on the contact detail page.  I was able to use the roll-up field type at the account level and display on the account page, but I haven't figured out how to do this at the opportunity contact role level and display on the contact page.  I was thinking I would have to create a visual force page or an s-control to do this, but if there is an easier way please share.  Thanks;

 

 

mtbclimbermtbclimber
Right, we don't support Roll-up summary formulas across lookup or many2many relationships like Contact<-OpportunityContactRole->Opportunity. Not to mention this may be fairly complicated if I understand  you correctly.  Are you saying that for a given contact that has 2 opportunities with 3 different products you want to see a list of the products and for each the total amount across all opportunites? So you can answer the question, "How much of product A, B & C has this contact "purchased"(or at least has had on opportunities) from us"?
jostendjostend
Yes, Here is an example.  On the contact record for Joe Smith, he has 3 opportunities.  Often this can be 40 or 50 records.
Opp 1   GMT   10,000
Opp 2   GMT     5,000
Opp 3   P2       23,000

I would like to show a summary:
Blue Ridge Co      Joe Smith  GMT 15,000
Blue Ridge Co      Joe Smith   P2    23,000

I found an example on how to create a custom object using triggers, but we are using the professional version.
mtbclimbermtbclimber
Ahh. Sorry you aren't going to be able to accomplish this as you've stated.  The reason is that we only allow downward traversal across relationships of one level in Visualforce using standard controllers and you need to go down to opportunitycontactrole, up to opportunity and then down again to opportunitylineitem.  The second downward traversal is not allowed which means you need a custom controller which means Apex which as you know is not available to Professional Edition customers.