Skip to main content

Error when deleting documentary proof record: A constraint violation has prevented the data from being deleted

Error message when trying to delete documentary proof record.

H
Written by Harry Ledger
Updated over 2 weeks ago

Overview

This article explains how to resolve an issue where a documentary proof file cannot be deleted because it is still linked to an employeeโ€™s right to work record.

This error occurs when a file is automatically associated with the Right to Work Summary, and that link must be removed before deletion is possible.

๐Ÿ“Œ Note: If the file has been linked to multiple employees (e.g. in error), it will still appear "in use" even after you dissociate it from the employee you are reviewing.


Remove the link to delete the file

You must first remove the links between the Right to Work Summary and the documentary proof file before you can delete it.

  1. Click Employees, then Employees, then Right to Work.

  2. Open the relevant employee record.

  3. On the Right to Work Summary tab, scroll down and locate the Documentary Proof sections.

  4. Delete the problematic documentary proof links by clicking the small cross (โœ–) within each field.

  5. Click Save.

  6. Go to Documentary Proof and highlight the record you wish to delete.

  7. Click Delete.

If the error still occurs after following these steps, move on to the section below.


Steps to identify other linked records

You may need to identify whether another employee is still linked to the same proof file.

  1. Log in to the SelectHR Administrator Tool.

  2. Click Import/Export Data.

  3. Click Create an export definition.

  4. Click Select the data to export.

  5. Change the database to SelectHR.

  6. Log in.

  7. Copy and paste the SQL below into the SQL window:

    SELECT 
    p.[Person Number],
    p.[First Name],
    p.Surname,
    s.[Effective Status],
    we.[Person Number] AS [WorkEligibilityPersonNumber],
    we.[Exemption From Scheme Reason],
    we.[Working Time Directive Opt Out Date],
    we.[Right to Work Nationality],
    we.Sponsored,
    we.[Review Required],
    rw.[Right to Work Number],
    we.[Effective Right to Work Number 1] AS [Document 1],
    we.[Effective Right to Work Number 2] AS [Document 2],
    we.[Effective Right to Work Number 3] AS [Document 3],
    we.[Work Eligibility Notes]
    FROM Person.[Work Eligibility] we
    RIGHT JOIN Person.Details p
    ON p.[Person Number] = we.[Person Number]
    INNER JOIN Person.Snapshot s
    ON p.[Person Number] = s.[Person Number]
    LEFT JOIN Person.[Right to Work] rw
    ON p.[Person Number] = rw.[Person Number]
    WHERE p.[First Name] = 'CHANGEME'
    AND p.[Surname] = 'CHANGEME';
  8. Change the first name and surname values to match the employee you are investigating.

  9. Click Data to return results.

  10. If no duplicate employee is found, make a note of the Document 1 / Document 2 / Document 3 values in the results.

  11. Click the Query tab again.

  12. Remove the first name and surname criteria from the SQL.

  13. Update the query to filter by the Document Number(s) noted in step 10.

  14. Click Data to return all employee records using the same documentary proof file.

  15. Once you've identified all associated employees, repeat Section 1 to remove the documentary proof file from their Right to Work forms.

After all links have been removed, you will be able to delete the file successfully.

Did this answer your question?