Applies to Product - Dynamics 365 Human Resources
What’s happening?
While trying to create a new employee record, the following error was encountered: “Cannot create a record in Environment ID constraint (HCMEmploymentIDConstraint). The record already exists.”
Reason:
The error is caused by the “NextRec” field in the “SequenceNumberTable” not reflecting the values for Employment ID in the “HcmEmployment” and “HcmEmploymentConstraint” tables. This discrepancy is likely due to records being added through the data entity instead of the UI, with the Employment ID specified in the inbound data. Consequently, the code does not increment “NextRec” on the sequence number table.
Resolution:
Update the Employment number sequence:
- Navigate to Human resources > Setup > Human resources shared parameters > Number sequences tab > Employment reference to find the number sequence to check.
- Open the number sequence by right clicking and selecting View details, and check the value in Next field and Format field.
- If the “NextRec” value is smaller than the value in Next field, update the “NextRec” value for Employment ID to be one value greater than the largest value in the “HcmEmployment” and “HcmEmploymentIdConstraint” tables:
- Ensure that the Format for Employment ID is considered, as it might not be entirely numeric.
