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
The new LearnerThe new Learner 

Need to populate the sum of amount value based on the record type - - urgent

Hi Experts, 
I have one complicated requirement I am not big developer to complete so I approached here, kindly hello me out my requirement is I have three record types called A, B, C now 
 I need total C record type opportunities amount have to populate on parent of that B record type opportunities and populated amount value on B record type plus  sum of all the B record type opportunities amount value need to populate on record type A opportunity record. Kindly help me 
Abdul KhatriAbdul Khatri
The record types name A, B, C are the real name or you have just make it as an example.

How you are Hierarchically defining A parent of B, B parent of C? If you can shared some design insight.

Is there a possibility Record types may increase in future?
 
Abdul KhatriAbdul Khatri
No My question is, What identify who is the parent of who. You wanted to hard code that in the code?
Abdul KhatriAbdul Khatri
You requirement is little wierd, anyway if you wanted to achieve without entering a single line of code. With that option, I would suggest to create three Roll-Up Summary on Account Object. Please see the screen shot as an example for one. You can duplicate that for RecordType B, C

User-added image

It will look something like this on the Account Page, which you don't need to show anyways.
User-added image

Then On Opportunity Page create a formula Field like this

User-added image

Here is the sample code for your reference from the above image . Change it as per your need
IF( RecordType.Name = 'A' , Account.Opportunity_Total_Amount_For_B__c , 
  IF ( RecordType.Name = 'B' , Account.Opportunity_Total_Amount_For_B__c , 0  ) 
)

I hope is that what you needed. If not let me know.
Abdul KhatriAbdul Khatri
I think you didn't read the entire post. In the end I have provided you a formula field on the Opportunity Here is the last part where you create a formula field on the Opportunity which will reference those fields.

User-added image
Abdul KhatriAbdul Khatri
This is all point n click. Save you writing a tons of code.
Abdul KhatriAbdul Khatri
Yes Sir, I based RecordType A, B and C.

You can replace with your actual names. If any issues let me know.
Abdul KhatriAbdul Khatri
Yes, the correct formula will be sorry for that but I think you got it
 
IF( RecordType.Name = 'A' , Account.Opportunity_Total_Amount_For_B__c , 
  IF ( RecordType.Name = 'B' , Account.Opportunity_Total_Amount_For_C__c , 0  ) 
)

 
Abdul KhatriAbdul Khatri
You can do this
 
IF( RecordType.Name = 'A' , Account.Opportunity_Total_Amount_For_B__c + Account.Opportunity_Total_Amount_For_C__c , 
  IF ( RecordType.Name = 'B' , Account.Opportunity_Total_Amount_For_C__c , 0  ) 
)

 
Abdul KhatriAbdul Khatri
No problem.
Abdul KhatriAbdul Khatri
How that is possible, On Opportunity Account is always a mandatory field (Out of Box). Can you please send me the screen shot of showing how that is possible?
Abdul KhatriAbdul Khatri
I am not sure if they removed that, Do you know in which Release they removed. My Sandboxes are in Winter '19 and I still see them mandatory. 

Are you able to save opportunity without AccountId? Anyway I would investigate but in the mean time if that is what you are seeing, I would suggest to make it mandatory through the Page Layout router.
Abdul KhatriAbdul Khatri
Can you send me the screen shot of the Page Layout for the Record Type A and B in the Edit Mode, I need to check how it looks. Thanks.

Can't you make it mandatory?

Other think if you don't specified the Account on the Opportunity, How you know the Opportunity is for what Account/Contact?