Tag: Primary Email

Get Email , phone from CustTable or DirPartyTable

 

HI, Sample code to get primary email if not other email based on Party Id.

FieldId primaryFieldId = DirPartyTable::electronicAddressType2primaryFieldId(LogisticsElectronicAddressMethodType::Email);

//Get Primary

select firstonly logisticsElectronicAddress
join dirPartyTable
where logisticsElectronicAddress.Locator != ”
&& logisticsElectronicAddress.type == LogisticsElectronicAddressMethodType::Email
&& dirPartyTable.(primaryFieldId) == logisticsElectronicAddress.RecId
&& dirPartyTable.RecId == custTable.Party;

salesTable.Email = logisticsElectronicAddress.Locator;
if(!logisticsElectronicAddress.Locator)
{

//Get other email
select firstonly logisticsElectronicAddress
join Party,Location from dirPartyLocation
where logisticsElectronicAddress.Locator != ”
&& logisticsElectronicAddress.type == LogisticsElectronicAddressMethodType::Email
&& dirPartyLocation.Party == custTable.Party
&& logisticsElectronicAddress.Location == dirPartyLocation.Location;

salesTable.Email = logisticsElectronicAddress.Locator;
if(!salesTable.Email)
salesTable.Email = custEmail;
}