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
AnuShAnuSh 

How to Creating an Opportunity object field count to show in Product object field.

Hi Guys,

Need some help !!

I'm new to Apex Developing. I'm trying to create the opportunities count in the Product object. 
Note: Account object is not Master Details (A read-only field that displays the sum, minimum, or maximum value of a field in a related list or the record count of all records listed in a related list.)

So guide me in other way to create opportunity count in product object field.
SwarnaSankhaSinghSwarnaSankhaSingh

Hi AnuSh,

You state "I'm trying to create the opportunities count in the Product object". Based on the next statement where you talk about Account, I am guessing you want to create a field for Count of Opportunities on the Account Object? Or, do you want to create a field for Count of Opportunities on the Product Object (the Standard Product object which is what you select when creating Line Items for an Opportunity)?

Kind Regards,
Swarna.

AnuShAnuSh
Thanks for the reply Swarna
Sorry i was written Mistake

Count of Opportunities on the product Object (the Standard Product object which is what you select when creating Line Items for an Opportunity).
Thanks in advance

Regards
Anush
 
SwarnaSankhaSinghSwarnaSankhaSingh

Hi Anush,

There is no standard OOTB feature available to help you get this functionality in place. Now if you choose the route of Apex Code then I will not say it cannot be done but it will be a very complex logic because there is no direct relationship between an Opportunity and a Product. The relationship is indirect.

An Opportunity is comprised of Opportunity Products or Line Items and it is these line items which have a direct relationship to a Product. Please keep in mind that one Opportunity can have multiple line items and each line item can be linked to a different product. So the baseline requirement of have an Opportunity count on the Product is quite against the operational logic.

Can you share some details on why you need this count of the Opportunity on a Product because it really is of no significance unless you decide to get the Line Items into the picture?

Just for your information that you can very well generate a report to give you a detailed count of Opportunity Line items under each product. I created a summary reports in a few mins to give you and idea and attached the screenshot.

User-added image

Kind Regards,
Swarna.

AnuShAnuSh
Thank you  for the reply Swarna

Here is the scenario: How many opportunities has been created based on each product. I would like to know the count of opportunity line item based on each product. 

I Can easily create report , but I need at the product level .Let me know if you need any information on that. Thank you.



One question on Report :How to avoid Duplicates from the Product level reporting

Actual Scnario : Two objects :product and opportunity 
Report type : Product and opportunity ( Inner join) or left join

I need all the information related to product based on opportunity stage 
But I'm getting duplicate records.

Is there any way that can avoid the duplicate records.


Regards
AnuSh