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
MJFMJF 

Opportunity formula to add specific items

I am a VERY new user and i need a formula that when the opportunity is saved, it will calculate the total price of items with a specific word in the product code or description. Can anyone help with that?
Best Answer chosen by Admin (Salesforce Developers) 
tantotanto

I just built this out and tested it. Here is what you can do:

 

  • Create a custom text area field on Opportunity Products, cannot be a long text area as these are not available for rollup summaries.
  • Create a workflow rule with a field update. The field update should use a formula to pull in the Product description into the text area field you created above.
  • Create a roll up summary field that has filter criteria. Set the criteria operator to contains and in the value field enter the values that you want separated by commas, this is case sensitive.

This should accomplish what you are looking for. Please let me know if you need anything else.

All Answers

Shilpa_SFShilpa_SF

Hi,

 

     Could you try to explain what exact formula you may want to built. I understand that Line iem is a Child object for  Opportunity and if you want build a formula on Opportunity for the Total number of child items, you should use Rollup summary formula, but again you cannot add any condition to it. It just calculates the total price of all items.

 

     If your requirement is particularly conditional then you can only acheive this through apex code. Below is the link which can help you in building formula's

 

    http://wiki.developerforce.com/index.php/An_Introduction_to_Formulas

MJFMJF

 Hi Shilpa, 

 

 I need a formula that will look into each line item on an opportunity for a specific word or code (for example "tax") and then add up the total price of those items separately from the rest of the items. Out of ten items, there may be only two or three that match this criteria and I need those items to have a separate total.  

 

I will look into the link that you gave me and let you know if it is helpful -- Thanks!! 

tantotanto

Hello,

 

There is a way to but filters on roll up summary fields, however, the types of fields that are available for filtering is limited. Unfortunately, Producct Conde and Description are not available. You requirements can be solved with an Apex Trigger. I would recomment leveraging a Salesforce programmer to do this. If you need assistance please let me know, I am a developer.

MJFMJF

How about if i create a field in Opportunity Products that exactly match a field in the Product description itself? Would that work? And what formula could i use to have it pull the information form one field into the new field?

tantotanto

I just built this out and tested it. Here is what you can do:

 

  • Create a custom text area field on Opportunity Products, cannot be a long text area as these are not available for rollup summaries.
  • Create a workflow rule with a field update. The field update should use a formula to pull in the Product description into the text area field you created above.
  • Create a roll up summary field that has filter criteria. Set the criteria operator to contains and in the value field enter the values that you want separated by commas, this is case sensitive.

This should accomplish what you are looking for. Please let me know if you need anything else.

This was selected as the best answer
brettnnycbrettnnyc

I'm trying to accomplish something similar: do a Rollup Summary for each of my product family types one at a time that are part of an Opportunity via Opportunity Product Line Items. The problem is that Family Type is not one of the criteria selections in the Rollup Summary so I can't SUM the Price & Cost of each.

 

For instance, I have 16 Opportunity Products related to the one Opportunity. Our of those 16 there are 4 different Family types (Hors d'oeuvres, Glassware, Staff, Groceries). I want to create a field in the Opportunity that SUMs the price for each and cost for each.

 

What do I need to do to create for this to happen?

MJFMJF
On mine, I used the Rollup Summary and created a new field to select the criteria. For exampl i used "Taxable" and set it to yes or no. Then set up the Rollup Summary using the criteria of "Taxavle" equals "Yes". Mayby you could try creating a field that equals the Item Family field and use the new field in the criteria for the Rollup Summary.