-2

It was brought to my attention when changing some User Profiles so they don't have permissions to Delete any Leads or Accounts, that the same button to Delete is also tied to "Find Duplicates". So, if I unclick "Delete" so they cannot delete any, it also removes the "Find Duplicates" button so they can no longer use that as well. These buttons are tied together and they need to be separated. Just because I don't want a Sales Associate to be able to accidentally delete a Lead or Account, doesn't mean I also don't want them to be able to use the "Find Duplicates' button. This is used all day every day when they are trying to qualify leads by hitting that button to find duplicates and comparing their new lead to an old lead already in our system.

0

There's no "configuration-only" method for this, but you can still block the lead deletion with code. You just need to create a trigger that looks like this:

trigger NoLeadDelete on Lead (after delete) {
    for(Lead record: Trigger.old) {
        // MasterRecordId != null indicates a merge is occurring
        // MasterRecordId == null indicates this is a deletion
        if(record.MasterRecordId == null) {
            record.addError('You cannot delete lead records.');
        }
    }
}

You can do additional logic if you want to limit it to just certain profiles/permissions/etc. For example, you could allow users with ModifyAllData to skip the check:

trigger NoLeadDelete on Lead (after delete) {
    if(0 < [SELECT COUNT() 
            FROM PermissionSetAssignment 
            WHERE PermissionSet.PermissionsModifyAllData = true 
            AND AssigneeId = :UserInfo.getUserId()]) {
        return;
    }
    for(Lead record: Trigger.old) {
        if(record.MasterRecordId == null) {
            record.addError('You cannot delete lead records.');
        }
    }
}
  • Thanks, Actually I want to remove delete permission for some profiles but i want to find duplicate button. if I am remove delete permission in profile permission set then "find duplicate" button automatically gone. please help me on this. – Ankit Sharma Nov 21 '18 at 7:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.