Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How can I connect tables LogisticsElectronicAddress and HcmWorker?

(0) ShareShare
ReportReport
Posted on by 272

I need the PersonnelNumber from HcmWorker table, but the value I am receiving is an E-mail address from LogisticsElectronicAddress is there a possible connection/sql statement where I can find the PersonnelNumber by using the E-mail address? They are in the same form named HcmWorker

*This post is locked for comments

  • Rati Sharabidze Profile Picture
    612 on at
    RE: How can I connect tables LogisticsElectronicAddress and HcmWorker?

    Hello Miguel,

    Try this relation:

    logisticsElectronicAddress.Location == dirPartyLocation.Location

    && hcmWorker.Person == dirPartyLocation.Party

    && dirPerson.RecId == dirPartyLocation.Party

    Best regards

  • Jonathan  Halland Profile Picture
    11,306 on at
    RE: How can I connect tables LogisticsElectronicAddress and HcmWorker?

    Hi, as a note, Miguel, the code I have above relies on your email address being marked as a primary address on the worker, can you test that, otherwise use Kavitha's code

  • Pravasti AK Profile Picture
    2,985 on at
    RE: How can I connect tables LogisticsElectronicAddress and HcmWorker?

    Hi Miguel,

    Here is the code :

    private LogisticsElectronicAddressLocator getInstructorEmail(HcmWorkerRecId  _workerRecId)

    {

       LogisticsElectronicAddress  logisticsElectronicAddress;

       HcmWorker                   hcmWorker;

       DirPerson                   dirPerson;

       DirPartyTable               dirPartyTable;

       select hcmWorker

           where hcmWorker.RecId == _workerRecId

       join dirPerson

           where dirPerson.RecId == hcmWorker.Person

       join dirPartyTable

           where dirPartyTable.RecId == dirPerson.RecId

       join logisticsElectronicAddress

           where dirPartyTable.PrimaryContactEmail == logisticsElectronicAddress.RecId;

       return logisticsElectronicAddress.Locator;

    }

    Please refer the below link:

    http://axbooster.blogspot.fr/2014/06/get-employee-detail-by-code-ax-2012.html

  • Miguel Zuniga Profile Picture
    272 on at
    RE: How can I connect tables LogisticsElectronicAddress and HcmWorker?

    Tried it Jonathan but it just outputs the value 0

  • Suggested answer
    Jonathan  Halland Profile Picture
    11,306 on at
    RE: How can I connect tables LogisticsElectronicAddress and HcmWorker?

    Try trans.parmApprover(HcmWorker::findByPerson(dirPartyTable.RecId).RecId);

  • Miguel Zuniga Profile Picture
    272 on at
    RE: How can I connect tables LogisticsElectronicAddress and HcmWorker?

    Hi Jonathan,

    I am using this to import on an invoice journal using x++.

    trans.parmApprover(HcmWorker::findByPerson(dirPartyTable.RecId));

    using HcmWorker::findByPerson(dirPartyTable.RecId) gives me the error of "Argument '_approver' is incompatible with the required type"

  • Suggested answer
    Jonathan  Halland Profile Picture
    11,306 on at
    RE: How can I connect tables LogisticsElectronicAddress and HcmWorker?

    Hi Miguel,

    Obviously you can have multiple employees with the same email in AX, however if your data is logically arranged that it is not like this then you can use something like:

    public static HcmWorker getWorkerFromEmail(Email _address)
    {
        FieldId primaryFieldId = DirPartyTable::electronicAddressType2primaryFieldId(LogisticsElectronicAddressMethodType::Email);
        LogisticsElectronicAddress  logisticsElectronicAddress;
        DirPartyTable dirPartyTable;
        HcmWorker worker;
        ;
    
         select firstonly dirPartyTable
            exists join logisticsElectronicAddress
                where dirPartyTable.(primaryFieldId) == logisticsElectronicAddress.RecId
                && logisticsElectronicAddress.Locator == _address;
    
        return HcmWorker::findByPerson(dirPartyTable.RecId);
    }


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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics AX (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 100 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 48

#3
shanawaz davood basha Profile Picture

shanawaz davood basha 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans