+ Start a Discussion

Opportunity Parent/Child hierarchy - Is this possible?

I have just been asked by management to explore options managing one master opportunity comprised by group of individual opportunities. Today we are managing this individually and currently have no way to tie them together to represent the one opportunity.


I am looking for a way to:

  • Create one master opportunity 
  • Batch create child opportunity records (designated number) 
  • Roll-up the $ amount of child opportunity records to the $ amount of the master opportunity
  • Forecast/Report on the master opportunity to reflect open vs. closed as each individual opportunity is closed

Note: We utilize BigMachines for quoting


Use case:


There is one big project for Acme Telecom that's worth $1M. This is captured in SF.com as 1 opportunity for $1M. This customer has asked that we break out the project in 10 phases and provide 1 quote for each phase. Since we could only have 1 primary quote per opportunity, we would have to create 10 separate opportunities worth $100K per quote. 


However, our sales management would like to report/forecast the 1 opportunity. As each quote is booked, the respective opportunity would be closed in SF.com and reflected in the forecasts and reporting. Ultimately, we would end up with $1M of closed opportunities over the course of the FY. 


This is scenario starting to occur more frequently and it is becoming a nightmare to manage.  


Any ideas?

Shashikant SharmaShashikant Sharma

First you can not do it using the salesforce nativa rollUpSummary field as for this you have to have a Master Detail relationship to opprtunity it self which is not allowed.


I can suggest you to create a Lookup reference relationship field ParantOpportunity and create custom  Cuurency field for a rollUpSummary and write logic for rollup in trigger. 

What this trigger should do is whenever a opprtunity comes or updated we should check whether it has a parent then update the rollup Of parent to the top most hierarchy , a recursive function i what you will need to which will move from child to parent. Would require a  good logic. But surely looks possible to me.


Hello Shashikant,


Thanks for the reply. I will look into this. Another option would be for me to add a checkbox (multiple quotes?) and quantity (number) field on the initial oppportunity that, when saved, will trigger the insert of multiple related opportunity records. In my example, it would create 10 opportunity records. I assume that this would be possible, but would need a little help to get started. I can see where I would need to set a counter variable that is checked prior to inserting the record. The loop would end once the counter reached the number in the quantity field. 


Could you recommend how I could get started with this?

Shashikant SharmaShashikant Sharma

Yes that is good to start with and all the newly created opportunity would require a refrence to parent as well. Your trigger should be like this

trigger createNewCS on Opportunity (before update) 
    List<Opportunity > listChildOpportunity  = new List<Opportunity>();
    for(Opportunity o : trigger.new)
        if(o.multipleQutes__C == true)
          //here Opportunity__c is lookup to parent Opportunity record for which new record is created
          listChildOpportunity.add(new Opportunity (Opportunity__c = o.id));
          //You can set other fields to
    if(listChildOpportunity.size() > 0)
        insert listChildOpportunity;