Opportunity Product Permissions - Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
Mario Bianchi VivernMario Bianchi Vivern 

Opportunity Product Permissions

Hello,

I currently have permissions set for certain profiles not to be able to delete opportunities. What I also need to do is not allow them to delete any products assigned to the opportunities which they currently can still do.

Can't find a way to do this under Setup.

Thanks,
Best Answer chosen by Moderator (salesforce.com) 
Aaron DeRanAaron DeRan
+1 @ Mamoon

Create a RUS field on the Opporrtunity object that counts all Opportunity Products on it. 

Then create a validation rule like this:

PRIORVALUE(Product_Count__c) > Product_Count__c

You will get a prevent error when you attempt to delete an Opportunity Product.

Snaps... left page open... too slow.


All Answers

Mamoon HajjaMamoon Hajja
Hmm, have you tried creating a Rollup summary field on Opportunities from Opportunity Products and then having a Vaildation Rule on Opportunities that evaluates that Rollup Summary field? :)

Please don't forget to mark the best answer to your question, thanks!
Maria BelliMaria Belli
+1 Mamoon. Create a roll-up summary field on the Opportunity and see example of validation rule below:
----------------------
Description: Prevents users from deleting opportunity products. Create the following validation rule example on opportunities. It uses a custom roll-up summary field on opportunities that counts the number of opportunity products on an opportunity.
Formula:    

AND(
OR(
NOT(ISBLANK(TEXT( StageName ))),
Number_of_Line_Items__c < PRIORVALUE(Number_of_Line_Items__c)
)
)

Error Message:    Cannot delete opportunity products on opportunities.
Aaron DeRanAaron DeRan
+1 @ Mamoon

Create a RUS field on the Opporrtunity object that counts all Opportunity Products on it. 

Then create a validation rule like this:

PRIORVALUE(Product_Count__c) > Product_Count__c

You will get a prevent error when you attempt to delete an Opportunity Product.

Snaps... left page open... too slow.


This was selected as the best answer