You need to sign in to do that
Don't have an account?
Vetriselvan Manoharan
Adding discount to line item
Hi,
I need to add discount to line item dynamically. For eg: If a customer orders mac + iphone it should add 10% discount, mac + samssung 15% discount, again mac + iphone + samsung 25% should get added. It should check for all possible products and its discount. Can anyone help me with it?
Thanks,
Vetri
I need to add discount to line item dynamically. For eg: If a customer orders mac + iphone it should add 10% discount, mac + samssung 15% discount, again mac + iphone + samsung 25% should get added. It should check for all possible products and its discount. Can anyone help me with it?
Thanks,
Vetri
The requirement is not straight forward and would require customizations. I will help you with the design, and then may be you can start building the required objects etc.
Design Approach -
1. Custom Object (Product Discounts) - Create a new object that stores all possible combinations of products that can exist for an opportunity with the respective discounts. Use a multi-select picklist field for storing the Product Combinations.
2. On Creating a new Line Item record a piece of code should do the following -
- Query the Custom object with the product combination present on the respective opportunity including this newly created Product
- If the query returns a record then use the discount value mentioned in that record and update the opportunity Total Discount field
Example: If an Opportunity already has two line items with Products A and B respectively. When the user creates another line item with Product = C, the code should check if the Custom Object contains a record with the combination of A, B and C. If yes then the respective discount value should be used to update the Total Discount field on Opportunity.
Approach for checking Product Combination -
1. Use a multi-select picklist field for storing the Product Combinations and another field to store the discounts.
2. When a new line item is created, create a string containing all the Products for that opportunity delimited with a semicolon ';'
3. This should return a single record of the Custom Object that matches the same combination of Products
4. Use the discount value of the retrieved record and update the Total Discount field of Opportunity
Point to Consider -
You can choose between a Trigger and the new Process Builder for invoking this piece of code when a new line item record is created.
Sample lines of code to compare the combination of products with the Custom Object -
I have tried to be elaborative in explanation. I hope this solves your problem.
Thanks
AR
If you find this reply useful that solves your problem then please mark it as best answer.
All Answers
Please share some more information on this requirement as per the questions below -
- Can you elaborate more on how this discount is calculate for each combination of products chosen?
- Is there a table/object in Salesforce that maintains this information which needs to be referenced dynamically when a combination of product is chosen?
- As I understand, there will be a separate line item for each product eg. separate line items for mac and iPhone. So that means that you wish to kind-of roll up the individual discounts of each product onto the parent Quote (or which ever entity)?
Thanks
AR
Yes we are planning to have a custom object which has the combination of products and their discount. The line item will be seperate for each product. How do I get the combination correctly for applying discount in line item based on the combination.
Thanks,
Vetri
Also let me know where exactly this discount figure will be shown on the UI, because there will be separate line items for each product therefore it should be desirable to show it on the Parent object. Something like Total Discount.
Please confirm.
Thanks
AR
Hi Anupam,
Yes that would be fine I guess. We can show the discount in opportunity object and amount field in opportunity object should change based on it if the combination is correct. It would great if you help me to do it.
Thanks,
Vetri
The requirement is not straight forward and would require customizations. I will help you with the design, and then may be you can start building the required objects etc.
Design Approach -
1. Custom Object (Product Discounts) - Create a new object that stores all possible combinations of products that can exist for an opportunity with the respective discounts. Use a multi-select picklist field for storing the Product Combinations.
2. On Creating a new Line Item record a piece of code should do the following -
- Query the Custom object with the product combination present on the respective opportunity including this newly created Product
- If the query returns a record then use the discount value mentioned in that record and update the opportunity Total Discount field
Example: If an Opportunity already has two line items with Products A and B respectively. When the user creates another line item with Product = C, the code should check if the Custom Object contains a record with the combination of A, B and C. If yes then the respective discount value should be used to update the Total Discount field on Opportunity.
Approach for checking Product Combination -
1. Use a multi-select picklist field for storing the Product Combinations and another field to store the discounts.
2. When a new line item is created, create a string containing all the Products for that opportunity delimited with a semicolon ';'
3. This should return a single record of the Custom Object that matches the same combination of Products
4. Use the discount value of the retrieved record and update the Total Discount field of Opportunity
Point to Consider -
You can choose between a Trigger and the new Process Builder for invoking this piece of code when a new line item record is created.
Sample lines of code to compare the combination of products with the Custom Object -
I have tried to be elaborative in explanation. I hope this solves your problem.
Thanks
AR
If you find this reply useful that solves your problem then please mark it as best answer.
Thanks for idea!!! thats great. I will let you know if I need any help
Thanks,
Vetri