Sunday, August 23, 2015

Retrieve worker email address through X++

Below code snipet is one of the way to retrieve employee/worker's primary email address.

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

3 comments:

  1. Never mind, I am not sure about benefit of rewriting code if HcmWorker.email() can be used

    ReplyDelete
    Replies
    1. That's a good point, I did not check HcmWorker table. Thanks for your input Sohaib

      Delete
  2. Its very helpful if we need email/phone number based on the purpose e.g. Invoice, Delivery etc.

    ReplyDelete

I will appreciate your comments !

How to enable new Microsoft teams - Public Preview!

New Microsoft Teams is just AWESOME, quick but useful post below shows how you have this preview feature to make your life EASY!  Open Micr...