Following job can be used to reterieve customer contact information by type (email/telephone) and purpose (Business/Invoice)
static void JS_CustomerContactbyTypePurpose(Args _args)
{
CustTable custTable = CustTable::find("003764");
LogisticsElectronicAddress electronicAddresslocal;
LogisticsElectronicAddress getelectronicAddress(CustAccount CustAccount, // Customer Account
LogisticsElectronicAddressMethodType contactType = LogisticsElectronicAddressMethodType::Phone,
LogisticsLocationRoleType purpose = LogisticsLocationRoleType::Invoice)
{
LogisticsLocation parentLocation;
DirPartyLocation dirPartyLocation;
LogisticsElectronicAddress electronicAddress;
LogisticsElectronicAddressRole electronicAddressRole;
LogisticsLocationRole locationRole;
custTable _custtable;
select _custtable
where _custtable.accountNum == CustAccount// Specify customer account here
join dirPartyLocation
where dirPartyLocation.Party == custTable.Party
join parentLocation
where dirPartyLocation.Location == parentLocation.RecId
join electronicAddress
where electronicAddress.Location == parentLocation.RecId
&& electronicAddress.Type == contactType
join electronicAddressRole
where electronicAddressRole.ElectronicAddress == electronicAddress.RecId
join locationRole
where electronicAddressRole.LocationRole == locationRole.RecId
&& locationRole.Type == purpose;
{
return electronicAddress;
}
}
electronicAddresslocal = getelectronicAddress(custTable.AccountNum, LogisticsElectronicAddressMethodType::Phone, LogisticsLocationRoleType::Invoice);
info(strFmt("Customer: %1, Description: %2, Information %3", custTable.AccountNum, electronicAddresslocal.Description, electronicAddresslocal.Locator));
electronicAddresslocal = getelectronicAddress(custTable.AccountNum, LogisticsElectronicAddressMethodType::Email, LogisticsLocationRoleType::Invoice);
info(strFmt("Customer: %1, Description: %2, Information %3", custTable.AccountNum, electronicAddresslocal.Description, electronicAddresslocal.Locator));
}
No comments:
Post a Comment