Показать сообщение отдельно
Старый 26.07.2024, 18:12   #1  
Blog bot is offline
Blog bot
Участник
 
25,644 / 848 (80) +++++++
Регистрация: 28.10.2006
dynamicsaxinsight: D365: Get worker email address by purpose in X++
Источник: https://dynamicsaxinsight.com/2024/0...urpose-in-xpp/
==============

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{ /// /// Get email address by purpose Feb 16, 24 MK. /// /// /// Atlas Dynamics Pty Ltd. /// 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();


Источник: https://dynamicsaxinsight.com/2024/0...urpose-in-xpp/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.