When trying to Delete or Merge a record, "Delete Restricted By Foreign Key Error" error message.
This can occur on the Staff record when there are record types not included in the Staff Merge. For example, if the Staff member you are attempting to Merge has Commission records, Staff Account Transactions, Time Records or Project Incentive records, those records associated with the Staff you are trying to Merge will need to first be changed to the Staff record you plan to keep, after the Staff Merge.
Professional, Enterprise, Supportworks
You will need to locate all objects which have a Lookup relationship to the Staff object. This might be easier to find by narrowing your search based on the specific Org settings. Go to Setup > Report Types and begin creating a new Report Type of Staff (A) "with"... note the Objects (B) which are linked to Staff. This list includes all Objects with a Lookup Relationship to the Staff Object.
Search these (B) Objects for the Lookup Fields that contain the Staff record you're trying to delete/merge. Remember: you will not need to look on the Lead Source, Marketing Opportunity, Appointment, Sale, Project, or Project Activities as those Objects are included in the Staff Merge. Keep in mind, there may be Lookups to Staff on multiple separate objects (such as Commissions, CommissionCalcs and Staff Account Transactions). Due to custom objects as well as custom fields on managed objects, it may be rather time consuming to locate all these Lookup Relationship fields.
Example A: Receipt and Adjustment Object with Lookup to Staff
In this example, there was a Lookup field on the Receipts and Adjustments Object. The field labeled "Collected By" is tracking which Staff member collected a payment. The Staff member who would be Deleted during the Staff Merge has associated Receipts and Adjustments in which they are the "Collected By" staff member. In this example: Billy Sales Rep has payments that he has collected. Those payments will need to be associated to the Staff member we plan to keep after the Staff Merge (in this example, Billy Sales Rep ACTIVE).
Depending on how many Receipt and Adjustment records are tied to this Staff member, we may be able to change them all to the Staff member we plan to keep using a List View.
Step 1: On the Receipts and Adjustments Tab, create a List View to isolate the payments in which the "Collected By" staff member is the the Staff record we need to Merge. In this example, it is "Billy Sales Rep" and I need to replace the Collected By value with "Billy Sales Rep ACTIVE."
Step 2: Highlight all records in the List View, and double-click on Collected By field to change the value in that field. Choose the Staff member you plan to KEEP after the merge (in this example "Billy Sales Rep ACTIVE"), and choose to Apply Changes to All Selected records. Click Save.
Helpful Hint: A List View can display up to 200 records at a time. This means, you can modify the values of up to 200 records at a time. Be sure to select "Display 200 records per page" at the bottom left of the List View. Use the checkbox at the top of the column header to Select All records on the page.
Step 3: After the contents of the Lookup field are either cleared or changed to another Staff record, you should be able to complete the Staff Merge and successfully delete the Staff record without receiving a Foreign Key error message.
A Custom Object or a Custom Field on a Managed Object interacts with the native Staff Objects in a way that was not expected and interferes with deletion.
Or, the record you are trying to delete is being used in a lookup field that requires you to clear the lookup prior to deletion.