RDD Calculated Fields - INVCHEAD CustEmailAddress

Does anyone know what field the InvcHead.Calc_CustEmailAddress is coming from (on the report styles)? Maybe @Rich? Thanks for the help!

image

I believe the logic is:

  1. Pick the address of the primary billing contact on the customer record.
  2. Use the customer e-mail address if no billing contact is available.

Looking at the decompiled code in <server root>\Assemblies\Erp.Internal.AR.ARInvForm.dll, here is the relevant section, under DoInvcHeadCalculations():

this.CustEMailAddress = this.Customer.EMailAddress;
if (!this.InvcHead.SoldToInvoiceAddress)
{
    Customer bCustomer = Customer.FindFirstByPrimaryKey(this.Db, base.Session.CompanyID, this.InvcHead.SoldToCustNum);
    if (bCustomer != null)
    {
        this.CustContactName = "";
        CustCnt custCnt = this.FindFirstCustCnt(base.Session.CompanyID, bCustomer.CustNum, bCustomer.PrimBCon);
        if (!this.webOrder && custCnt != null)
        {
            this.CustContactName = custCnt.Name;
            this.CustFax = custCnt.FaxNum;
            this.CustPhone = custCnt.PhoneNum;
            this.CustEMailAddress = custCnt.EMailAddress;
        }
    }
}
else if (this.InvcHead.BillConNum != 0)
{
    CustCnt custCnt2 = this.FindFirstCustCnt2(base.Session.CompanyID, this.InvcHead.CustNum, this.InvcHead.BillConNum);
    if (custCnt2 != null)
    {
        this.CustContactName = custCnt2.Name;
        this.CustFax = custCnt2.FaxNum;
        this.CustPhone = custCnt2.PhoneNum;
        this.CustEMailAddress = custCnt2.EMailAddress;
    }
    else
    {
        this.CustContactName = "";
    }
}
else
{
    this.CustContactName = "";
}

I’m not the sharpest with C#, so someone correct me if I’m wrong… but if I’m reading this correctly the logic is:

  1. Start with the customer email address
  2. If there is no SoldTo Invoice Address but there is a SoldTo Customer (this doesn’t make sense to me), use the email of the primary billing contact on the SoldTo Customer
  3. Otherwise, if there is a Billing Contact, use the email address of the Billing Contact (Attn field of an order/shipment?)

Edit: this is in 10.2.500.0

1 Like

By default it will use the Bill To customer email address.

If “Print Sold To Address” is marked it will look for the primary billing contact of the Sold To Customer.

If not it will check if the primary billing contact number is populated and use it.

1 Like

Thanks @ckoch and @Jonathan. Neat idea to decompile the DLL. It’s amazing what a little digging can find out when it’s not documented. :slight_smile: