最新消息:ww12345678 的部落格重装上线,希望大家继续支持。

D365: Get worker email address by purpose in X++

网络文摘 William 26浏览 0评论

Purpose:

Demonstrate how can get the worker email address by purpose.

Application:

Dynamics 365 for Finance and Operations

Business requirement:

Business requirement is to display worker email address with purpose “Purchase order” in a report.

Solution:

We can use the method below to get the worker email address by purpose which is defined in the extension class of HcmWorker table.

Code

[ExtensionOf(tableStr(HcmWorker))]
internal final class ATLAS_HcmWorker_Table_Extension
{
    /// <summary>
    /// Get email address by purpose Feb 16, 24 MK.
    /// </summary>
    /// <remarks>
    /// Atlas Dynamics Pty Ltd.
    /// </remarks>
    public Email emailByPurpose(LogisticsLocationRoleName _name)
    {
        LogisticsElectronicAddressRole logisticsElectronicAddressRole;
        LogisticsElectronicAddress     logisticsElectronicAddress;
        LogisticsLocationRole          logisticsLocationRole;
        LogisticsLocation              logisticsLocation;
        DirPartyLocation               dirPartyLocation;
        DirPartyTable                  dirPartyTable;
        DirPerson                      dirPerson;

        select firstOnly logisticsElectronicAddress
            where logisticsElectronicAddress.Type == LogisticsElectronicAddressMethodType::Email
                join logisticsElectronicAddressRole
                    where logisticsElectronicAddressRole.ElectronicAddress == logisticsElectronicAddress.RecId
                join logisticsLocationRole
                    where logisticsLocationRole.RecId == logisticsElectronicAddressRole.LocationRole
                        && logisticsLocationRole.Name == _name
                join logisticsLocation
                    where logisticsLocation.RecId == logisticsElectronicAddress.Location
                join dirPartyLocation
                    where dirPartyLocation.Location == logisticsLocation.RecId
                join dirPartyTable
                    where dirPartyTable.RecId == dirPartyLocation.Party
                join dirPerson
                    where dirPerson.RecId == dirPartyTable.RecId
                        && dirPerson.RecId == this.Person;

        return logisticsElectronicAddress.Locator;
    }

}

We can then call this method in the following way to initialize temp table buffer.

purchOrderLineTmp.DimOwnerEmail = (hcmWorker.emailByPurpose(#PurchaseOrder)) ? (hcmWorker.emailByPurpose(#PurchaseOrder)) : hcmWorker.email();
发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址