[SalesForce] Unable to restrict delete permissions on Opportunity Line Items

I am trying to restrict users by profile from being able to delete opp line itmes. For example I have a communities partner profile and under the standard object permissions against the opportunity (master record of the line item) there is no box to either allow or disallow delete rights.

enter image description here

If I login as one of these users and look at the list view of opportunities there is no delete option – this is correct.

If we look at the corresponding list of opp line items they do have the delete option so this is not consistant.

enter image description here

This problem is not specific to partners user profiles either, I checked a standard profile and the delete option for the opp is explicitly not ticked yet they also can delete the line items.

I understood that the edit/delete rights to the master object should also apply to the detail records.

How can I configure the settings to restrict certain profiles from being able to delete both the opportunity and its individual line items?

If its not possible in the settings then we will do it with a before delete trigger and only allow a few admin profiles but I would assume a basic permission like this can be done without any code.

Best Answer

This issue is addressed on the Salesforce Success Forum

  1. Create RSF field on Opportunity OpportunityProductCount__c that is a count of all Opportunity Products on the Opportunity
  2. Create a Validation Rule on Opportunity:

    AND(PRIORVALUE(OpportunityProductCount__c) > OpportunityProductCount__c,
        $Profile.name = 'Foo')
    
Related Topic