Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Want to check employee record if it matches with the new applicant

Posted on by 502

Hello all,

I want to check duplicate employee record with the new applicant if employee name ,DOB and passport number matches with New applicant record with Name, Dob and passport number.

If new applicant record matches with existing record, the system must through warning message.

Validation at applicant record creation:

Trigger: On save of an applicant record.

Can I have to write code on the post handler of validatewrite()?

Where and what code can be written to do so.

Thank you

Siddhant Singh

*This post is locked for comments

  • Siddhant Singh Profile Picture
    Siddhant Singh 502 on at
    RE: Want to check employee record if it matches with the new applicant

    Hi Guru,

    Actually when the new applicant is entered by the user it gets entered. After that New Application will be created with the same name of the applicant and when the user saves the New Application, the system has to check with that if (Name and Dob) or (Name and Passport number) or (Dob and Passport number) matches it should show warning message.

    And I have written the code on data source of the for HRMApplication Form by extending the form and copying the post handler onValidateWrite of the data source as whenever the data source is hit after the save the system will chack for the values required for the validation.

  • Guruprasanna Profile Picture
    Guruprasanna 1,048 on at
    RE: Want to check employee record if it matches with the new applicant

    Hi Siddhant,

    as per my understanding,"BirthDate" and "Passport" fields are not a mandatory fields for creating employee. When you click new button on the employee form only name and employee date are the mandatory fields. Hence you can enter either "Birth date" or "Passport" number after the employee creation. However you can find the duplicate employee based on the employee name, Birth Date and pass port number fields. So, for this we have to write code in postEventHandler of "validateWrite" method of the "HcmPersonPrivateDetails". Please find the below piece of code.

    [PostHandlerFor(tableStr(HcmPersonPrivateDetails), tableMethodStr(HcmPersonPrivateDetails, validateWrite))]
    public static void HcmPersonPrivateDetails_Post_validateWrite(XppPrePostArgs args)
    {
    HcmPersonPrivateDetails privateDetails = args.getThis();
    DirPersonName personNameCurrent = DirPersonName::find(privateDetails.Person);
    HcmIdentificationType identificationType = HcmIdentificationType::findByIdentificationType("Passport");
    DirPersonName personNameOrig;
    HcmPersonIdentificationNumber identificationNumberOrig;
    HcmPersonIdentificationNumber identificationNumber = HcmPersonIdentificationNumber::findByPersonAndType(privateDetails.Person, identificationType.RecId);
    HcmPersonPrivateDetails privateDetailsOrig;

    select * from personNameOrig
    where personNameOrig.FirstName == personNameCurrent.FirstName
    && personNameOrig.LastName == personNameCurrent.LastName
    && personNameOrig.RecId != personNameCurrent.RecId
    exists join identificationNumberOrig
    where identificationNumberOrig.IdentificationType == identificationType.RecId
    && identificationNumberOrig.IdentificationNumber == identificationNumber.IdentificationNumber
    && identificationNumberOrig.Person == personNameOrig.Person
    exists join privateDetailsOrig
    where privateDetailsOrig.BirthDate == privateDetails.BirthDate
    && privateDetailsOrig.Person == personNameOrig.Person;

    if (personNameOrig)
    {
    checkFailed("Required error message");
    args.setReturnValue(false);
    }
    }

    Write similar code on the post event handler of "validateWrite" method of "HcmPersonIdentificationNumber" table because user can enter first birthdate then passport number or vice versa.

    I hope this might help you !

    regards

    Guru

  • Siddhant Singh Profile Picture
    Siddhant Singh 502 on at
    RE: Want to check employee record if it matches with the new applicant

    Hello guru,

    I have written method and call it in the post handler dirPersonName.

    pastedimage1563953261088v1.png

    pastedimage1563953353260v2.png

    pastedimage1563953369395v3.png

    These errors are coming.

    Thank you

    Siddhant Singh

  • Guruprasanna Profile Picture
    Guruprasanna 1,048 on at
    RE: Want to check employee record if it matches with the new applicant

    Hi Siddhant,

    you can write the code in the "onValidatingWrite" events of the "DirPersonName" table. If you open validate write method of this table you can see similar type of validation is exists for the name. And you can use the similar query something like below.

    DirPersonName personName;
    HcmPersonIdentificationNumber identificationNumber;
    HcmPersonPrivateDetails personPrivateDetails;
    HcmIdentificationType identificationType = HcmIdentificationType::findByIdentificationType("Passport");

    select * from personName
    where personName.FirstName == "Firstname"
    && personName.LastName == "LastName"
    exists join identificationNumber
    where identificationNumber.IdentificationType == identificationType.RecId
    && identificationNumber.IdentificationNumber == "PassportNumber"
    && identificationNumber.Person == personName.Person
    exists join personPrivateDetails
    where personPrivateDetails.BirthDate == "birthDate"
    && personPrivateDetails.Person == personName.Person;

    If you find the records for the above combination then you can throw the warning message.

    I hope this might help you

    Regards

    Guru

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans