web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Cannot create a record in Employment (HcmEmployment).

(0) ShareShare
ReportReport
Posted on by

Whenever I am trying to insert a record in HcmEmployment table through a .csv file, it is giving following error in infolog.

Cannot create a record in Employment (HcmEmployment). Invalid value specified for 'Employment end date'. It cannot be greater than or equal to the 'Employment end date' of the first record.

I finally deleted all the records from HcmEmployment table and only tried to insert one record, but it is stikll showing the above error.

*This post is locked for comments

  • Suggested answer
    Jesus R. ABASCAL Profile Picture
    1,450 on at

    I think the trouble is in End Date field. Are you check the convertion is OK? Debug and check if value of date is correct.

  • Community Member Profile Picture
    on at

    Okay I will ask my colleague to check.

  • Community Member Profile Picture
    on at

    We are using following function

    public static date convDate(str _date)

    {

       Date ret;

       ;

       ret = str2date(_date, 213);

       return ret;

    }

  • Suggested answer
    Jesus R. ABASCAL Profile Picture
    1,450 on at

    If you have no records in the table, I think the date value can be wrong. So, you should set a breakpoint into the convDate function and check the return value (ret) is a correct date.

  • Community Member Profile Picture
    on at

    Okay Abascal I will check it.

  • Suggested answer
    syed baber Profile Picture
    11,633 on at

    Hi Mahesh,

    In HcmEmployment table, there is a unique index on the following fields:

    Worker, LegalEntity, ValidFrom and ValidTo. So while inserting records, make sure that you are not violating this index. Furthermore, this is a date effective table, so you need to make sure that ValidFrom and ValidTo dates doesn't overlap between two records. I think the date effective framework so some adjustments automatically and change ValidTo of new records based on the new value, but do verify after the records are inserted successfully.

    Thanks,

    Baber.

  • Community Member Profile Picture
    on at

    Baber. Do you have any code to import Employee data into dynamics using X++ like HCMWoker and so on.

    The links we have in Google are very less like Krishnablogspot and all.

    If possible please help.

  • Sohaib Cheema Profile Picture
    49,668 Super User 2026 Season 2 on at

    although focus should be to resolve original problem, despite here goes the code to create employee

    community.dynamics.com/.../155550

    you can extend it as per your need

  • Community Member Profile Picture
    on at

    Thanks Sohaib I will check it. I don't know why Google is not displaying this search result .

  • syed baber Profile Picture
    11,633 on at

    Hi Mahesh,

    Why are you not using Data import export framework to import records into HcmWorker? The DIXF framework will take care of all validations.

    Please let me know if you need any help related to that.

    Thanks,

    Baber.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Prashant Singh Profile Picture

Prashant Singh 2

#1
nmaenpaa Profile Picture

nmaenpaa 2 Moderator

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans