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
b.gonzalezb.gonzalez 

How do you reference opportunity product fields in a formula on a custom object related to opportunity?

I created a custom object called: On-Going Reveneye by Fiscal Quarter. This custom object is related to Opportunity object.

I need to be able to calculate the Remaining Quanity for a product that appears on the opportunity ( see image below). Does anyone know if this is possible?

Is it possible to write a formula that will match the product on the Opportuntity line item to the product on the On-Going revenue related list, then subtract quantities to get the remaining quantity?

User-added image

I appreciate the help!

Thanks!

Beth
Abhishek BansalAbhishek Bansal
Hi,

There are two cases for your requirement :

Case 1 : If opportunity is related to your custom object by a master-detail relationship than you have to create two rollup summary fields on opportunity and than you will create a formula field on your custom obejct as follows :
1st Rollup field - Will sum Quantity of OLI
2nd Rollup field - Will sum Quantity of custom object records.
Formula field - 1st Rollup - 2nd Rollup

Case 2 : If opportunity is related as lookup than you cannot create a fromula field .
In this case you have to create a trigger on your custom object and handle the functionality accordingly.

Please let me know if anything is still not clear to you or you need any help.

Regards,
Abhishek