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
jack-cepheidjack-cepheid 

Discount Formula

I’m trying to build out some formula based fields and I’m unable to do a certain function no matter what I try. What I want to do is build a formula that will calculate discounts based on the Total quantity of products that are in an opportunity. Now there is a standard Total Opportunity Quantity field but it does not give me the calculation that I need. I need the calculation to look at the Quantity of the part number in the opportunity and multiply that by a custom field in the Product record that says how many items are in that part number. This calculation would need to be duplicated for each product (limited by a certain group of product families of course) and the total either returned to a custom field as  number or just used in the formula to figure a discount. An example would be…In the Product setup. Part number M-120 has a custom field that says that part number contains 120 items                                Part number G-10 has a custom field that says that part number contains 10 items            Both are assigned to the same product familyIn the OpportunityCustomer XYZ            Is ordering 3 of part number M-120            And 5 of part number G-10 (the standard SFDC field would say the opportunity quantity is 8) I want a formula to be able to see that 3 of part number M-120 =360 itemsAnd that 5 of part number G-10 = 50 items So the total number of items for that product family is 410 The discount would just be a greater/less than calculation that would say that the quantity is eligible for a 3% discount. Please let me know if there is a way to make that formula… Again I can do this for individual products right now but I need to do it one level higher at the opportunity level.
Best Answer chosen by Admin (Salesforce Developers) 
jack-cepheidjack-cepheid

Since I'm not that good with writing code yet (just learning now) I found  a temporary workaround that is functional.

 

I have a manual entry field in each product that would by "Product volume". On that field I put a validation rule that says that the value in "Product  volume" must equal Part number X items in part number (or what my formula would have been in the first place)

 

That allowed me to use the Roll Up Summary field for the Opportunity to determine my discounts.

 

Thanks for your help

 

All Answers

JakesterJakester
I'm having a really hard time following - could you try again, this time using the [Enter] key a few times in some logical places?
jack-cepheidjack-cepheid

Sorry i copied it from an email i had sent and assumed the format stayed.

Try this one...

 

I’m trying to build out some formula based fields and I’m unable to do a certain function no matter what I try. What I want to do is build a formula that will calculate discounts based on the Total quantity of products that are in an opportunity. Now there is a standard Total Opportunity Quantity field but it does not give me the calculation that I need. I need the calculation to look at the Quantity of the part number in the opportunity and multiply that by a custom field in the Product record that says how many items are in that part number. This calculation would need to be duplicated for each product (limited by a certain group of product families of course) and the total either returned to a custom field as  number or just used in the formula to figure a discount. 

 

An example would be…

In the Product setup. Part number mrsa-120 has a custom field that says that part number contains 120 items                               

                               Part number GBS-10 has a custom field that says that part number contains 10 items           

                               Both are assigned to the same product family

In the Opportunity

                         Customer XYZ           

                                Is ordering 3 of part number M-120           

                                And 5 of part number G-10 (the standard SFDC field would say the opportunity quantity is 8) 

 

I want a formula to be able to see that 3 of part number M-120 =360 items

                                           And that 5 of part number G-10 = 50 items 

                                          So the total number of items for that product family is 410 

 

The discount would just be a greater/less than calculation that would say that the quantity is eligible for a 3% discount. 

Please let me know if there is a way to make that formula…

Again I can do this for individual products right now but I need to do it one level higher at the opportunity level.

JakesterJakester

Try this. From the line item, you can get to the product info by using this syntax PricebookEntry.Product2.Your_Field__c

Then sum up the formula fields on the line items using a roll-up summary field.

jack-cepheidjack-cepheid

I see what you mean but it didn't work.

the Roll up summary would not show my formula field in the options.

JakesterJakester
I was afraid of that - I think I've run into that. I think it won't allow u to use RSF on formulas that reference child objects. You're going to have to use Apex Triggers if you want to stay fully native in SF. My workaround for this sort of thing, since I'm a SQL database guy, is to use DBAmp and then I can schedule updates to SF based on SQL calculations. There are many other routes you can take, too, depending on your technical ability and what tools you want to use and how long of a delay you can live with.
jack-cepheidjack-cepheid

Since I'm not that good with writing code yet (just learning now) I found  a temporary workaround that is functional.

 

I have a manual entry field in each product that would by "Product volume". On that field I put a validation rule that says that the value in "Product  volume" must equal Part number X items in part number (or what my formula would have been in the first place)

 

That allowed me to use the Roll Up Summary field for the Opportunity to determine my discounts.

 

Thanks for your help

 

This was selected as the best answer
JakesterJakester
Neat trick! Thanks for sharing it.