Monday, 19 March 2018

Get Email for Customer / Vendor (with specific roles)

To get an email address for a customer or vendor, you can use the following statement


static void Cust_emailStmtjob(Args _args)
{
    CustTable                                        cust; //Replace with vendTable for Vendors
    DirPartyLocation                                        dirPartyLocation;
    LogisticsElectronicAddress            elecAddress;
    LogisticsElectronicAddressRole    elecAddressRole;
    LogisticsLocationRole                    locRole;
   
    select firstOnly cust
        where cust.AccountNum == '‪‪‪us-001';
    while select DirPartyLocation
        where dirPartyLocation.party == cust.Party
    {
        while select elecAddress
            where elecAddress.Location == dirPartyLocation.Location
                   && elecAddress.Type == LogisticsElectronicAddressMethodType::Email
        {
            while select elecAddressRole
                where elecAddressRole.ElectronicAddress == elecAddress.RecId
                    join locRole
                        where locRole.RecId == elecAddressRole.LocationRole
                            && locRole.Name == "Invoice"
            {
                info(strFmt("%1 - %2", elecAddress.Locator, locRole.Name));
            }
        }
    }

}

No comments:

Post a Comment