Data directive to send an email when a OrderDtl field changes works, except the Customer Name

10.2.200.15
I am looking for help trying to set a variable Name to Customer.Name in order to pass that variable to the Send Email block.
I set up the variable “Name” as a string.
I first set a condition: The ttOrderDtl.Date04 field has changed from any to another
Then I execute custom code:
Erp.Tables.Customer Customer;
Name = System.Convert.ToString(Db.Customer.Name);
I then build the email in the Send Email block:
image
No compilation errors, yet the email contains what looks like junk in the reference field.
image
Thanks for your consideration.
Paul

Here is my working example on how I access DB in a BPM…for OrderHed table…

var HedRows = Db.OrderHed.Where(x => ((x.Company == Row.Company) && ( x.OrderNum == Row.OrderNum )   ));
if( HedRows.Count() > 0 )
{		
									
	foreach( var Hed in HedRows)
	{
              myvar = Hed["ShipViaCode"].ToString();
         }
}

But you may use .FirstOrDefault() at end of the where to get the first row only…?

Pierre

So much obliged Pierre,
Check Syntax throws “The name ‘Row’ does not exist in the current context”

Sorry…Row was from another foreach related to my orderrel table…

Your directive came from which event? OrderDtl date change…

I always start by verifying if tt table is not null

if(ttOrderDtl != null)
{
     foreach(var Row in (from r in ttOrderDtl where ( (r.RowMod == "A") || (r.RowMod == "U") ) select r))  
    {
       // put your customer code in here? but I think you need orderhed to know your custnum of the order
      //  You then need to access Orderhed table with another db access
var HedRows = Db.OrderHed.Where(x => ((x.Company == Row.Company) && ( x.OrderNum == Row.OrderNum )   ));
	if( HedRows.Count() > 0 )
	{		
										
	      foreach( var Hed in HedRows)
		{
                      //now here put your customer code referencing custnum = hed.Custnum...
                      //Once you gather the customer name, put it into a callContext field to use it in your e-mail
                      callContextBpmData.Character01 = name_of_customer...
                }
       }

Then in your email you can use the callContextData to show…

Pierre

Bless you Pierre. That worked like a charm.