web
You’re offline. This is a read only version of the page.
close
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

I have the same question (0)
  • Suggested answer
    Jonathan  Halland Profile Picture
    11,310 on at

    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);
    }


  • Miguel Zuniga Profile Picture
    272 on at

    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,310 on at

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

  • Miguel Zuniga Profile Picture
    272 on at

    Tried it Jonathan but it just outputs the value 0

  • Pravasti AK Profile Picture
    2,985 on at

    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

  • Jonathan  Halland Profile Picture
    11,310 on at

    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

  • Rati Sharabidze Profile Picture
    612 on at

    Hello Miguel,

    Try this relation:

    logisticsElectronicAddress.Location == dirPartyLocation.Location

    && hcmWorker.Person == dirPartyLocation.Party

    && dirPerson.RecId == dirPartyLocation.Party

    Best regards

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans