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

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s